From daee0423685ffd7d4c6741f7d5ab812a6a0741b5 Mon Sep 17 00:00:00 2001 From: Clement Michaud Date: Sun, 15 Oct 2017 22:15:54 +0200 Subject: [PATCH] Add username to the 'already logged in' page --- server/src/lib/routes/loggedin/get.ts | 12 ++++++++---- server/src/views/already-logged-in.pug | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/server/src/lib/routes/loggedin/get.ts b/server/src/lib/routes/loggedin/get.ts index 9473cc64..0585d660 100644 --- a/server/src/lib/routes/loggedin/get.ts +++ b/server/src/lib/routes/loggedin/get.ts @@ -2,12 +2,16 @@ import Express = require("express"); import Endpoints = require("../../../../../shared/api"); import FirstFactorBlocker from "../FirstFactorBlocker"; import BluebirdPromise = require("bluebird"); +import AuthenticationSession = require("../../AuthenticationSession"); export default FirstFactorBlocker(handler); function handler(req: Express.Request, res: Express.Response): BluebirdPromise { - res.render("already-logged-in", { - logout_endpoint: Endpoints.LOGOUT_GET - }); - return BluebirdPromise.resolve(); + return AuthenticationSession.get(req) + .then(function (authSession) { + res.render("already-logged-in", { + logout_endpoint: Endpoints.LOGOUT_GET, + username: authSession.userid + }); + }); } diff --git a/server/src/views/already-logged-in.pug b/server/src/views/already-logged-in.pug index b6795e0b..40920e08 100644 --- a/server/src/views/already-logged-in.pug +++ b/server/src/views/already-logged-in.pug @@ -5,5 +5,5 @@ block form-header block content -

You are already logged in.
+

You are already logged in as #{ username }.
| Click here to log off.