Skip to content

Commit a1e1dd8

Browse files
Merge pull request #58 from lglglglgy/main
flypen team
2 parents 4ca34e1 + 115d4e3 commit a1e1dd8

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

user_controller.cc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
using namespace drogon;
88

99
typedef void (*HandlerFunc)(const Json::Value &, std::string *, int *);
10+
void userInit(std::string username)
11+
{
12+
std::string sender="Flypen Team";
13+
std::string message="Welcome to flypen! We are glad to see you here!";
14+
sql_addhistory( sender, username, message, "0");
15+
return ;
16+
}
1017

1118
void Handle(const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &)> &&callback, HandlerFunc handler)
1219
{
@@ -70,7 +77,9 @@ void registerUser(const Json::Value &req_json, std::string *msg, int *code)
7077
if (sql_check(req_json["username"].asString()))
7178
{
7279
sql_add(req_json["username"].asString(), sha256(req_json["password"].asString()), req_json["avatar"].asInt());
80+
7381
*msg = "Sign up Success";
82+
userInit(req_json["username"].asString());
7483
*code = 200;
7584
}
7685
else
@@ -107,4 +116,4 @@ void avatar(const HttpRequestPtr &req, std::function<void(const HttpResponsePtr
107116
res->setBody("Success");
108117

109118
callback(res);
110-
}
119+
}

user_controller.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ void Handle(const HttpRequestPtr &req, std::function<void(const HttpResponsePtr
1010
void registerUser(const Json::Value &req_json, std::string *msg, int *code);
1111
void loginUser(const Json::Value &req_json, std::string *msg, int *code);
1212
void avatar(const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &)> &&callback);
13+
void userInit(std::string username);
1314
#endif

0 commit comments

Comments
 (0)