Skip to content

Commit 679c0a2

Browse files
committed
userinit
1 parent f525d90 commit 679c0a2

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

user_controller.cc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
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+
}
1016

1117
void Handle(const HttpRequestPtr &req, std::function<void(const HttpResponsePtr &)> &&callback, HandlerFunc handler)
1218
{
@@ -70,7 +76,9 @@ void registerUser(const Json::Value &req_json, std::string *msg, int *code)
7076
if (sql_check(req_json["username"].asString()))
7177
{
7278
sql_add(req_json["username"].asString(), sha256(req_json["password"].asString()), req_json["avatar"].asInt());
79+
7380
*msg = "Sign up Success";
81+
userInit(req_json["username"].asString());
7482
*code = 200;
7583
}
7684
else
@@ -107,4 +115,4 @@ void avatar(const HttpRequestPtr &req, std::function<void(const HttpResponsePtr
107115
res->setBody("Success");
108116

109117
callback(res);
110-
}
118+
}

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)