Skip to content

Commit

Permalink
feat(auth): conditionally render auth providers (#16)
Browse files Browse the repository at this point in the history
Added flags to toggle GitHub and Microsoft auth in the UI based on
availability, improving UX by showing only enabled options.
  • Loading branch information
piotrski authored Oct 18, 2024
1 parent 7e9503e commit 2f6cfee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
6 changes: 3 additions & 3 deletions api/script/routes/passport-authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 9 additions & 5 deletions api/script/views/authenticate.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,15 @@
<div class="container">
Please select an authentication provider for your CodePush account:<br />
<br />
<a href="/auth/<%=action%>/github"><img class="github" src="images/GitHub.png"> GitHub</a>
<span class="spacer"/>
<a href="/auth/<%=action%>/microsoft"><img class="microsoft" src="images/windows10.png"> Microsoft (Personal)</a>
<span class="spacer"/>
<a href="/auth/<%=action%>/azure-ad"><img class="microsoft" src="images/windows10.png"> Microsoft (Work)</a><br />
<% if (isGitHubAuthenticationEnabled) { %>
<a href="/auth/<%=action%>/github"><img class="github" src="images/GitHub.png"> GitHub</a>
<span class="spacer"/>
<% } %>
<% if (isMicrosoftAuthenticationEnabled) { %>
<a href="/auth/<%=action%>/microsoft"><img class="microsoft" src="images/windows10.png"> Microsoft (Personal)</a>
<span class="spacer"/>
<a href="/auth/<%=action%>/azure-ad"><img class="microsoft" src="images/windows10.png"> Microsoft (Work)</a><br />
<% } %>
</div>
</body>
</html>

0 comments on commit 2f6cfee

Please sign in to comment.