Skip to content

Commit

Permalink
Merge pull request microsoft#333 from derkoe/feat/show-only-enabled-auth
Browse files Browse the repository at this point in the history
Show only enabled authentication mechanisms
  • Loading branch information
davidxw authored Sep 11, 2024
2 parents 47f4aa9 + e5d279e commit f98e27d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ export default async function Home() {
await redirectIfAuthenticated();
return (
<main className="container max-w-lg flex items-center">
<LogIn isDevMode={process.env.NODE_ENV === "development"} />
<LogIn
isDevMode={process.env.NODE_ENV === "development"}
githubEnabled={!!process.env.AUTH_GITHUB_ID}
entraIdEnabled={!!process.env.AZURE_AD_CLIENT_ID}
/>
</main>
);
}
14 changes: 10 additions & 4 deletions src/features/auth-page/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import {

interface LoginProps {
isDevMode: boolean;
githubEnabled: boolean;
entraIdEnabled: boolean;
}

export const LogIn: FC<LoginProps> = (props) => {
Expand All @@ -31,13 +33,17 @@ export const LogIn: FC<LoginProps> = (props) => {
</CardDescription>
</CardHeader>
<CardContent className="grid gap-4">
<Button onClick={() => signIn("github")}>GitHub</Button>
<Button onClick={() => signIn("azure-ad")}> Microsoft 365</Button>
{props.isDevMode ? (
{props.githubEnabled && (
<Button onClick={() => signIn("github")}>GitHub</Button>
)}
{props.entraIdEnabled && (
<Button onClick={() => signIn("azure-ad")}>Microsoft 365</Button>
)}
{props.isDevMode && (
<Button onClick={() => signIn("localdev")}>
Basic Auth (DEV ONLY)
</Button>
) : null}
)}
</CardContent>
</Card>
);
Expand Down

0 comments on commit f98e27d

Please sign in to comment.