From 3811a260248b6103bbd973fdfdafe679a99786e1 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 21 Mar 2020 19:00:08 +0100 Subject: [PATCH] Can get security settings --- src/controllers/Routes.ts | 2 ++ src/controllers/SettingsController.ts | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/controllers/Routes.ts b/src/controllers/Routes.ts index e19df96..6bd3b51 100644 --- a/src/controllers/Routes.ts +++ b/src/controllers/Routes.ts @@ -91,6 +91,8 @@ export const Routes : Route[] = [ {path: "/settings/set_language", cb: (h) => SettingsController.SetLanguage(h)}, + {path: "/settings/get_security", cb: (h) => SettingsController.GetSecurity(h)}, + // Friends controller {path: "/friends/getList", cb: (h) => FriendsController.GetList(h)}, diff --git a/src/controllers/SettingsController.ts b/src/controllers/SettingsController.ts index 11824df..fac1919 100644 --- a/src/controllers/SettingsController.ts +++ b/src/controllers/SettingsController.ts @@ -135,4 +135,23 @@ export class SettingsController { h.success(); } + + /** + * Get security settings + * + * @param h Request handler + */ + public static async GetSecurity(h: RequestHandler) { + await h.needUserPostPassword("password"); + + const userInfo = await UserHelper.GetUserInfo(h.getUserId()); + + h.send({ + id: userInfo.id, + security_question_1: userInfo.hasSecurityQuestion1 ? userInfo.security_question_1 : "", + security_answer_1: userInfo.hasSecurityAnswer1 ? userInfo.security_answer_1 : "", + security_question_2: userInfo.hasSecurityQuestion2 ? userInfo.security_question_2 : "", + security_answer_2: userInfo.hasSecurityAnswer2 ? userInfo.security_answer_2 : "", + }); + } } \ No newline at end of file