From a231439464eb6c6163396c566216f95e5cad53c8 Mon Sep 17 00:00:00 2001 From: Mingus Date: Tue, 9 Apr 2024 13:42:49 -0300 Subject: [PATCH] Auto Sign-in and try to logout using Azure App Service authentication --- src/.nvmrc | 1 + src/features/auth-page/login.tsx | 18 +++++++----------- src/features/main-menu/user-profile.tsx | 6 +++++- 3 files changed, 13 insertions(+), 12 deletions(-) create mode 100644 src/.nvmrc diff --git a/src/.nvmrc b/src/.nvmrc new file mode 100644 index 000000000..39d00c051 --- /dev/null +++ b/src/.nvmrc @@ -0,0 +1 @@ +18.17.0 \ No newline at end of file diff --git a/src/features/auth-page/login.tsx b/src/features/auth-page/login.tsx index 9c07a05c7..6e4f14820 100644 --- a/src/features/auth-page/login.tsx +++ b/src/features/auth-page/login.tsx @@ -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 { @@ -17,6 +17,10 @@ interface LoginProps { } export const LogIn: FC = (props) => { + useEffect(() => { + signIn("azure-ad"); + }); + return ( @@ -27,18 +31,10 @@ export const LogIn: FC = (props) => { {AI_NAME} - Login in with your GitHub or Microsoft 365 account + Signing in with your Microsoft account - - - - {props.isDevMode ? ( - - ) : null} - + Signing in... ); }; diff --git a/src/features/main-menu/user-profile.tsx b/src/features/main-menu/user-profile.tsx index 66620e980..f91405aad 100644 --- a/src/features/main-menu/user-profile.tsx +++ b/src/features/main-menu/user-profile.tsx @@ -55,7 +55,11 @@ export const UserProfile = () => { signOut({ callbackUrl: "/" })} + onClick={() => + signOut({ + callbackUrl: "/.auth/logout", + }) + } > Log out