Merge pull request #219 from gradido/login_add_user_to_json_login

User Object on Json Login
This commit is contained in:
Moriz Wahl 2021-04-22 11:08:08 +02:00 committed by GitHub
commit bafe77ed10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 58 additions and 5 deletions

View File

@ -48,11 +48,36 @@ In case of success returns:
```json
{
"state":"success",
"user": {
"created": 1614782270,
"disabled": false,
"email": "max.musterman@gmail.de",
"email_checked": true,
"first_name": "Max",
"group_alias": "gdd1",
"ident_hash": 323769895,
"last_name": "Mustermann",
"public_hex": "131c7f68dd94b2be4c913400ff7ff4cdc03ac2bda99c2d29edcacb3b065c67e6",
"role": "none",
"username": ""
}
"session_id": -127182,
"clientIP":"123.123.123.123"
}
```
- `user`: contain user object
- `created`: timestamp on which account was created
- `disabled`: true if account was disabled, if disabled no login or coin transfer is possible
- `email`: email of user
- `email_checked`: true if user has successfully clicked on activation link in email
- `first_name`: first name of user
- `group_alias`: alias of group/community to which user belong
- `ident_hash`: currently hash of email, will be later a identification hash to prevent multiple accounts and therefore multiple creations per user
- `last_name`: last name of user
- `public_hex`: public key of user in hex format
- `role`: role of user currently only "none" or "admin"
- `username`: not used yet
- `clientIP`: should be the same as where the js-client is running, else maybe a man-in-the-middle attacks is happening or
nginx was wrong configured.
- `session_id`: can be also negative
@ -265,6 +290,19 @@ In case of success returns:
{
"state":"success", "email_verification_code_type":"resetPassword",
"info":[],
"user": {
"created": 1614782270,
"disabled": false,
"email": "max.musterman@gmail.de",
"email_checked": true,
"first_name": "Max",
"group_alias": "gdd1",
"ident_hash": 323769895,
"last_name": "Mustermann",
"public_hex": "131c7f68dd94b2be4c913400ff7ff4cdc03ac2bda99c2d29edcacb3b065c67e6",
"role": "none",
"username": ""
}
"session_id":1853761475
}
```
@ -274,8 +312,20 @@ In case of success returns:
- `registerDirect`: code generated by register for check email
- `register`: code generated by auto-register via elopage for check email
- `info`: can contain additional info strings
- "user hasn't password": if user hasn't set a password yet (for example if he was registered via elopage)
- "user has no password": if user hasn't set a password yet (for example if he was registered via elopage)
- "email already activated": if email was already checked
- `user`: contain user object
- `created`: timestamp on which account was created
- `disabled`: true if account was disabled, if disabled no login or coin transfer is possible
- `email`: email of user
- `email_checked`: true if user has successfully clicked on activation link in email
- `first_name`: first name of user
- `group_alias`: alias of group/community to which user belong
- `ident_hash`: currently hash of email, will be later a identification hash to prevent multiple accounts and therefore multiple creations per user
- `last_name`: last name of user
- `public_hex`: public key of user in hex format
- `role`: role of user currently only "none" or "admin"
- `username`: not used yet
- `session_id`: session_id for new session
## Send E-Mails

View File

@ -53,18 +53,20 @@ Poco::JSON::Object* JsonLoginViaEmailVerificationCode::handle(Poco::Dynamic::Var
result->set("session_id", session->getHandle());
result->set("email_verification_code_type", model::table::EmailOptIn::typeToString(session->getEmailVerificationType()));
Poco::JSON::Array info;
if (!session->getNewUser()->getModel()->getPasswordHashed()) {
info.add("user hasn't password");
auto user = session->getNewUser();
if (!user->getModel()->getPasswordHashed()) {
info.add("user has no password");
}
auto update_email_verification_result = session->updateEmailVerification(code);
if (1 == update_email_verification_result) {
info.add("email already activated");
}
result->set("user", user->getJson());
result->set("info", info);
return result;
}
}

View File

@ -102,6 +102,7 @@ Poco::JSON::Object* JsonUnsecureLogin::handle(Poco::Dynamic::Var params)
case USER_COMPLETE:
case USER_EMAIL_NOT_ACTIVATED:
result->set("state", "success");
result->set("user", session->getNewUser()->getJson());
result->set("session_id", session->getHandle());
session->setClientIp(mClientIP);
return result;