From c58984fe526e43a6d526e9fcd5a2e4f7c2ab4818 Mon Sep 17 00:00:00 2001 From: Piotr Tomczewski Date: Thu, 10 Oct 2024 14:16:08 +0200 Subject: [PATCH] feat(auth): conditionally render auth providers Added flags to toggle GitHub and Microsoft auth in the UI based on availability, improving UX by showing only enabled options. --- api/script/routes/passport-authentication.ts | 6 +++--- api/script/views/authenticate.ejs | 14 +++++++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/api/script/routes/passport-authentication.ts b/api/script/routes/passport-authentication.ts index 488d0d75a..46bb8f28a 100644 --- a/api/script/routes/passport-authentication.ts +++ b/api/script/routes/passport-authentication.ts @@ -167,17 +167,17 @@ export class PassportAuthentication { router.get("/auth/login", this._cookieSessionMiddleware, (req: Request, res: Response): any => { req.session["hostname"] = req.query.hostname; - res.render("authenticate", { action: "login" }); + res.render("authenticate", { action: "login", isGitHubAuthenticationEnabled, isMicrosoftAuthenticationEnabled }); }); router.get("/auth/link", this._cookieSessionMiddleware, (req: Request, res: Response): any => { req.session["authorization"] = req.query.access_token; - res.render("authenticate", { action: "link" }); + res.render("authenticate", { action: "link", isGitHubAuthenticationEnabled, isMicrosoftAuthenticationEnabled }); }); router.get("/auth/register", this._cookieSessionMiddleware, (req: Request, res: Response): any => { req.session["hostname"] = req.query.hostname; - res.render("authenticate", { action: "register" }); + res.render("authenticate", { action: "register", isGitHubAuthenticationEnabled, isMicrosoftAuthenticationEnabled }); }); return router; diff --git a/api/script/views/authenticate.ejs b/api/script/views/authenticate.ejs index cb6218986..33251b46f 100644 --- a/api/script/views/authenticate.ejs +++ b/api/script/views/authenticate.ejs @@ -85,11 +85,15 @@
Please select an authentication provider for your CodePush account:

- GitHub - - Microsoft (Personal) - - Microsoft (Work)
+ <% if (isGitHubAuthenticationEnabled) { %> + GitHub + + <% } %> + <% if (isMicrosoftAuthenticationEnabled) { %> + Microsoft (Personal) + + Microsoft (Work)
+ <% } %>