Backend support for Apple login
This commit is contained in:
@@ -9,6 +9,7 @@ long account_calls(CVars in, CVars &out);
|
||||
long LoginWrenchBoardAccount( CVars in, CVars &out );
|
||||
long LoginWrenchBoardFacebook( CVars in, CVars &out );
|
||||
long LoginWrenchBoardGoogle( CVars in, CVars &out );
|
||||
long LoginWrenchBoardApple( CVars in, CVars &out );
|
||||
long LoginWrenchBoardExternal( CVars in, CVars &out );
|
||||
long SessionCheck(long uid, const char *sessionid, int create );
|
||||
long account_session_check(CVars in, CVars out);
|
||||
|
||||
@@ -145,6 +145,7 @@ enum { PARTNER_STRIPE };
|
||||
#define WRENCHBOARD_ACCOUNT_LOGIN 11025
|
||||
#define WRENCHBOARD_FACEBOOK_LOGIN 11026
|
||||
#define WRENCHBOARD_GOOGLE_LOGIN 11027
|
||||
#define WRENCHBOARD_APPLE_LOGIN 11031
|
||||
#define WRENCHBOARD_START_JOBLIST 11028
|
||||
#define WRENCHBOARD_ACCOUNT_DASHDATA 11029
|
||||
|
||||
|
||||
@@ -218,6 +218,10 @@ long account_calls(CVars in, CVars &out) {
|
||||
return LoginWrenchBoardGoogle(in, out);
|
||||
break;
|
||||
|
||||
case WRENCHBOARD_APPLE_LOGIN:
|
||||
return LoginWrenchBoardApple(in, out);
|
||||
break;
|
||||
|
||||
case WRENCHBOARD_ACCOUNT_PENDING:
|
||||
return CreateWrenchBoardAccountPending(in, out);
|
||||
break;
|
||||
@@ -1323,6 +1327,24 @@ long LoginWrenchBoardGoogle(CVars in, CVars &out) {
|
||||
return res;
|
||||
}
|
||||
|
||||
long LoginWrenchBoardApple(CVars in, CVars &out) {
|
||||
long res = PHP_API_BAD_PARAM;
|
||||
logfmt(logINFO, "LoginWrenchBoardApple()");
|
||||
REQ_STRING(in, "apple_id", 5, 49, "(.*)");
|
||||
in["external_idp_provider_id"] = in["apple_id"];
|
||||
in["external_idp_provider"] = 3L; // Apple
|
||||
in["apple_id"].set_valid(false);
|
||||
REQ_STRING(in, "email", 6, 49, "(.*)");
|
||||
OPTIONAL(in, "firstname") REQ_STRING(in, "firstname", 1, 49, "(.*)");
|
||||
else in["firstname"] = "";
|
||||
OPTIONAL(in, "lastname") REQ_STRING(in, "lastname", 1, 49, "(.*)");
|
||||
else in["lastname"] = "";
|
||||
REQ_STRING(in, "sessionid", 4, 40, "(.*)");
|
||||
OPTIONAL(in, "loc") REQ_STRING(in, "loc", 3, 15, "(.*)");
|
||||
res = LoginWrenchBoardExternal(in, out);
|
||||
logfmt(logINFO, "/LoginWrenchBoardApple()");
|
||||
return res;
|
||||
}
|
||||
|
||||
long LoginWrenchBoardExternal(CVars in, CVars &out) {
|
||||
long res = PHP_API_BAD_PARAM;
|
||||
@@ -1337,7 +1359,7 @@ long LoginWrenchBoardExternal(CVars in, CVars &out) {
|
||||
} else {
|
||||
ret = load_db_record(out, "SELECT *,id AS member_id FROM members WHERE LOWER(email)=LOWER('%s') AND external_idp_provider_id='%s' AND external_idp_provider=%ld", in["email"].c_str(), in["external_idp_provider_id"].c_str(), in["external_idp_provider"].Long());
|
||||
if (ret > 0) {
|
||||
logfmt(logINFO, "FB account already exists");
|
||||
logfmt(logINFO, "External account already exists");
|
||||
} else {
|
||||
logfmt(logINFO, "Create new FB account");
|
||||
CVars xx;
|
||||
|
||||
Reference in New Issue
Block a user