diff --git a/src/controllers/AccountController.ts b/src/controllers/AccountController.ts index 57bd224..94d146e 100644 --- a/src/controllers/AccountController.ts +++ b/src/controllers/AccountController.ts @@ -94,4 +94,25 @@ export class AccountController { 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 + ] + }) + } } \ No newline at end of file diff --git a/src/controllers/Routes.ts b/src/controllers/Routes.ts index 18facc9..0533ab0 100644 --- a/src/controllers/Routes.ts +++ b/src/controllers/Routes.ts @@ -47,6 +47,8 @@ export const Routes : Route[] = [ {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 {path: "/user/getInfo", cb: (h) => UserController.GetSingle(h), needLogin: false},