From 35457401085de3923b5d76d00257d88bba1f536f Mon Sep 17 00:00:00 2001 From: JuliusMoehring <44407680+JuliusMoehring@users.noreply.github.com> Date: Tue, 7 Nov 2023 18:32:31 +0100 Subject: [PATCH] Add basic login screen | add logout button --- app/components/sidebar.tsx | 37 +++++++++++++++++++++++++++---------- app/constant.ts | 2 +- app/icons/signout.svg | 1 + app/login/login.module.scss | 25 +++++++++++++++++++++++++ app/login/page.tsx | 34 +++++++++++++++++++++++++++++++--- 5 files changed, 85 insertions(+), 14 deletions(-) create mode 100644 app/icons/signout.svg create mode 100644 app/login/login.module.scss diff --git a/app/components/sidebar.tsx b/app/components/sidebar.tsx index 56a9fe78b..502118183 100644 --- a/app/components/sidebar.tsx +++ b/app/components/sidebar.tsx @@ -1,16 +1,16 @@ -import { useEffect, useRef, useCallback } from "react"; +import { useEffect, useRef } from "react"; import styles from "./home.module.scss"; -import { IconButton } from "./button"; -import SettingsIcon from "../icons/settings.svg"; -import GithubIcon from "../icons/github.svg"; -import ChatGptIcon from "../icons/chatgpt.svg"; import AddIcon from "../icons/add.svg"; import CloseIcon from "../icons/close.svg"; +import DragIcon from "../icons/drag.svg"; +import GithubIcon from "../icons/github.svg"; import MaskIcon from "../icons/mask.svg"; import PluginIcon from "../icons/plugin.svg"; -import DragIcon from "../icons/drag.svg"; +import SettingsIcon from "../icons/settings.svg"; +import SignoutIcon from "../icons/signout.svg"; +import { IconButton } from "./button"; import Locale from "../locales"; @@ -25,9 +25,10 @@ import { REPO_URL, } from "../constant"; +import { signOut } from "next-auth/react"; +import dynamic from "next/dynamic"; import { Link, useNavigate } from "react-router-dom"; import { useMobileScreen } from "../utils"; -import dynamic from "next/dynamic"; import { showConfirm, showToast } from "./ui-lib"; const ChatList = dynamic(async () => (await import("./chat-list")).ChatList, { @@ -148,11 +149,17 @@ export function SideBar(props: { className?: string }) { AdExGPT - via API
- secure local UI for OpenAI API
- FAQ & Support + secure local UI for OpenAI API +
+ + FAQ & Support +
- +
@@ -202,16 +209,26 @@ export function SideBar(props: { className?: string }) { }} /> +
} shadow />
+
} shadow />
+ +
+ } + shadow + onClick={() => signOut()} + /> +
\ No newline at end of file diff --git a/app/login/login.module.scss b/app/login/login.module.scss new file mode 100644 index 000000000..db51c8e58 --- /dev/null +++ b/app/login/login.module.scss @@ -0,0 +1,25 @@ +.container { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + height: 100%; + gap: 16px; + width: 100%; + max-width: 560px; + padding: 16px; +} + +.headline { + text-align: center; +} + +.subline { + text-align: center; +} + +.sign-in-button { + width: 100%; + max-width: 260px; + text-decoration: none; +} diff --git a/app/login/page.tsx b/app/login/page.tsx index c664ce79a..edb3660f3 100644 --- a/app/login/page.tsx +++ b/app/login/page.tsx @@ -1,8 +1,14 @@ "use client"; -import { signIn } from "next-auth/react"; +import { signIn, useSession } from "next-auth/react"; +import Link from "next/link"; +import { IconButton } from "../components/button"; + +import styles from "./login.module.scss"; export default function Login() { + const session = useSession(); + const handleLogin = async () => { signIn("azure-ad", { callbackUrl: "/", @@ -10,8 +16,30 @@ export default function Login() { }; return ( -
- +
+

Welcome to AdEx GPT

+ +

+ Before you can start using AdEx GPT you have to sign in using your AdEx + account. After a successful sign in you will be redirected to the chat. +

+ + {session.status === "authenticated" ? ( + + + + ) : ( + + )}
); }