1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2024-11-26 07:19:23 +00:00

Can get security questions of the user

This commit is contained in:
Pierre HUBERT 2019-12-30 08:16:10 +01:00
parent 4297cabd7e
commit 95069423f5
2 changed files with 23 additions and 0 deletions

View File

@ -94,4 +94,25 @@ export class AccountController {
defined: settings.hasSecurityQuestions defined: settings.hasSecurityQuestions
}) })
} }
/**
* Get the security questions of a user, in order to reset its
* password
*
* @param h Request handler
*/
public static async GetSecurityQuestions(h: RequestHandler) {
const userID = await h.postUserIdFromEmail("email");
const settings = await UserHelper.GetUserInfo(userID);
if(!settings.hasSecurityQuestions)
h.error(401, "Specified user has not setup security questions !");
h.send({
questions: [
settings.security_question_1,
settings.security_question_2
]
})
}
} }

View File

@ -47,6 +47,8 @@ export const Routes : Route[] = [
{path: "/account/has_security_questions", cb: (h) => AccountController.HasSecurityQuestions(h), needLogin: false}, {path: "/account/has_security_questions", cb: (h) => AccountController.HasSecurityQuestions(h), needLogin: false},
{path: "/account/get_security_questions", cb: (h) => AccountController.GetSecurityQuestions(h), needLogin: false},
// User controller // User controller
{path: "/user/getInfo", cb: (h) => UserController.GetSingle(h), needLogin: false}, {path: "/user/getInfo", cb: (h) => UserController.GetSingle(h), needLogin: false},