From 6119d5d0ff66932f000628eefe391805e242ed10 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 23 Nov 2019 13:48:16 +0100 Subject: [PATCH] Get current user ID --- src/controllers/AccountController.ts | 10 ++++++++++ src/controllers/Routes.ts | 3 +++ 2 files changed, 13 insertions(+) diff --git a/src/controllers/AccountController.ts b/src/controllers/AccountController.ts index 6b3e808..15ec87c 100644 --- a/src/controllers/AccountController.ts +++ b/src/controllers/AccountController.ts @@ -41,4 +41,14 @@ export class AccountController { }); } + /** + * Get current user ID + * + * @param handler + */ + public static CurrentUserID(handler: RequestHandler) { + handler.send({ + userID: handler.getUserId() + }); + } } \ No newline at end of file diff --git a/src/controllers/Routes.ts b/src/controllers/Routes.ts index 552c5ff..03a835c 100644 --- a/src/controllers/Routes.ts +++ b/src/controllers/Routes.ts @@ -28,4 +28,7 @@ export const Routes : Route[] = [ // Account controller {path: "/account/login", cb: AccountController.LoginUser, needLogin: false}, {path: "/user/connectUSER", cb: AccountController.LoginUser, needLogin: false}, // Legacy + + {path: "/account/id", cb: AccountController.CurrentUserID}, + {path: "/user/getCurrentUserID", cb: AccountController.CurrentUserID}, // Legacy ] \ No newline at end of file