From 5c834e269bfff00b92ee63862cbbc7165743de9e Mon Sep 17 00:00:00 2001 From: "Alex Pooley (@zuedev)" Date: Wed, 13 May 2026 16:36:35 +0100 Subject: add better-auth --- .../red-right-hand/174bg.net/src/app/login/page.js | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 communities/red-right-hand/174bg.net/src/app/login/page.js (limited to 'communities/red-right-hand/174bg.net/src/app/login') diff --git a/communities/red-right-hand/174bg.net/src/app/login/page.js b/communities/red-right-hand/174bg.net/src/app/login/page.js new file mode 100644 index 0000000..b2b1ea8 --- /dev/null +++ b/communities/red-right-hand/174bg.net/src/app/login/page.js @@ -0,0 +1,51 @@ +"use client"; + +import { Suspense, useEffect, useState } from "react"; +import { useSearchParams } from "next/navigation"; +import { authClient } from "@/lib/auth-client"; + +function LoginRedirect() { + const searchParams = useSearchParams(); + const callbackUrl = searchParams.get("callbackUrl") ?? "/secure"; + const [error, setError] = useState(null); + + const signIn = () => { + authClient.signIn + .social({ + provider: "discord", + callbackURL: callbackUrl, + }) + .then(({ error }) => { + if (error) setError(error.message ?? "Sign-in failed"); + }); + }; + + useEffect(() => { + signIn(); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + + if (error) { + return ( +
+

Error: {error}

+ +
+ ); + } + + return ( +
+

Redirecting to Discord...

+ +
+ ); +} + +export default function LoginPage() { + return ( + Loading...

}> + +
+ ); +} -- cgit v1.2.3