Skip to content

Commit

Permalink
Auto Sign-in and try to logout using Azure App Service authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
megamingus committed Apr 16, 2024
1 parent abef4b8 commit a231439
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18.17.0
18 changes: 7 additions & 11 deletions src/features/auth-page/login.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";
import { AI_NAME } from "@/features/theme/theme-config";
import { signIn } from "next-auth/react";
import { FC } from "react";
import { FC, useEffect } from "react";
import { Avatar, AvatarImage } from "../ui/avatar";
import { Button } from "../ui/button";
import {
Expand All @@ -17,6 +17,10 @@ interface LoginProps {
}

export const LogIn: FC<LoginProps> = (props) => {
useEffect(() => {
signIn("azure-ad");
});

return (
<Card className="flex gap-2 flex-col min-w-[300px]">
<CardHeader className="gap-2">
Expand All @@ -27,18 +31,10 @@ export const LogIn: FC<LoginProps> = (props) => {
<span className="text-primary">{AI_NAME}</span>
</CardTitle>
<CardDescription>
Login in with your GitHub or Microsoft 365 account
Signing in with your Microsoft account
</CardDescription>
</CardHeader>
<CardContent className="grid gap-4">
<Button onClick={() => signIn("github")}>GitHub</Button>
<Button onClick={() => signIn("azure-ad")}> Microsoft 365</Button>
{props.isDevMode ? (
<Button onClick={() => signIn("localdev")}>
Basic Auth (DEV ONLY)
</Button>
) : null}
</CardContent>
<CardContent className="grid gap-4">Signing in...</CardContent>
</Card>
);
};
6 changes: 5 additions & 1 deletion src/features/main-menu/user-profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ export const UserProfile = () => {
<DropdownMenuSeparator />
<DropdownMenuItem
className="flex gap-2"
onClick={() => signOut({ callbackUrl: "/" })}
onClick={() =>
signOut({
callbackUrl: "/.auth/logout",
})
}
>
<LogOut {...menuIconProps} size={18} />
<span>Log out</span>
Expand Down

0 comments on commit a231439

Please sign in to comment.