From 314ae6db1037c0e07027ee884588ff7b4157842f Mon Sep 17 00:00:00 2001 From: NiazMorshed2007 Date: Wed, 12 Apr 2023 15:09:12 +0600 Subject: [PATCH 1/3] (feat): login page re-designed --- pages/api/auth/[...nextauth].js | 3 ++ pages/auth/signin.js | 63 +++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 pages/auth/signin.js diff --git a/pages/api/auth/[...nextauth].js b/pages/api/auth/[...nextauth].js index def7d7540ad..5493efc64a7 100644 --- a/pages/api/auth/[...nextauth].js +++ b/pages/api/auth/[...nextauth].js @@ -46,6 +46,9 @@ export const authOptions = { return session; }, }, + pages: { + signIn: "/auth/signin", + } }; export default NextAuth(authOptions); diff --git a/pages/auth/signin.js b/pages/auth/signin.js new file mode 100644 index 00000000000..cc92019de74 --- /dev/null +++ b/pages/auth/signin.js @@ -0,0 +1,63 @@ +import BlankLayout from "@components/layouts/BlankLayout" +import { getServerSession } from "next-auth/next" +import { getProviders, signIn } from "next-auth/react" +import { authOptions } from "pages/api/auth/[...nextauth]" +import { BsGithub } from "react-icons/bs" + +export default function SignIn({ providers }) { + + const handleProviderIcon = (provider_name) => { + if (provider_name === "GitHub") { + return + } + } + + return ( +
+
+ Your Company +

+ Connect to your audience + with a single link +

+ {Object.values(providers).map((provider) => ( + + ))} +
+
+ ) +} + +SignIn.getLayout = function getLayout(page) { + return ( + + {page} + + ) +} + + +export async function getServerSideProps(context) { + const session = await getServerSession(context.req, context.res, authOptions); + + // if the user is logged in redirect, (note: don't redirect to the same page otherwise it'll be in a infinite loop) + if (session) { + return { redirect: { destination: "/" } }; + } + + const providers = await getProviders(); + + return { + props: { providers: providers ?? [] }, + } +} \ No newline at end of file From a2f2d46852cf63238993dfe61b39004393dab160 Mon Sep 17 00:00:00 2001 From: NiazMorshed2007 Date: Sat, 15 Apr 2023 13:23:47 +0600 Subject: [PATCH 2/3] proposed-changes --- pages/auth/signin.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pages/auth/signin.js b/pages/auth/signin.js index cc92019de74..42148f8e493 100644 --- a/pages/auth/signin.js +++ b/pages/auth/signin.js @@ -20,15 +20,15 @@ export default function SignIn({ providers }) { src="/logo512.png" alt="Your Company" /> -

- Connect to your audience +

+ Connect to your audience with a single link

{Object.values(providers).map((provider) => ( From d0c9d3a39f620336ad24907e9a6ecf4f7d1d1883 Mon Sep 17 00:00:00 2001 From: NiazMorshed2007 Date: Sat, 29 Apr 2023 22:45:38 +0600 Subject: [PATCH 3/3] (update): custom login page --- pages/auth/signin.js | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/pages/auth/signin.js b/pages/auth/signin.js index 42148f8e493..60922fc8131 100644 --- a/pages/auth/signin.js +++ b/pages/auth/signin.js @@ -1,8 +1,27 @@ import BlankLayout from "@components/layouts/BlankLayout" import { getServerSession } from "next-auth/next" import { getProviders, signIn } from "next-auth/react" +import Image from "next/image" import { authOptions } from "pages/api/auth/[...nextauth]" import { BsGithub } from "react-icons/bs" +import { AiOutlineLock } from "react-icons/ai" + + +export async function getServerSideProps(context) { + const session = await getServerSession(context.req, context.res, authOptions); + + // if the user is logged in redirect, (note: don't redirect to the same page otherwise it'll be in a infinite loop) + if (session) { + return { redirect: { destination: "/account/statistics" } }; + } + + const providers = await getProviders(); + + return { + props: { providers: providers ?? [] }, + } +} + export default function SignIn({ providers }) { @@ -10,12 +29,15 @@ export default function SignIn({ providers }) { if (provider_name === "GitHub") { return } + return } return (
- Your Company ) -} - - -export async function getServerSideProps(context) { - const session = await getServerSession(context.req, context.res, authOptions); - - // if the user is logged in redirect, (note: don't redirect to the same page otherwise it'll be in a infinite loop) - if (session) { - return { redirect: { destination: "/" } }; - } - - const providers = await getProviders(); - - return { - props: { providers: providers ?? [] }, - } } \ No newline at end of file