Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(auth): conditionally render auth providers #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>