The hub as an OpenID Connect provider for T5DE Music
This commit is contained in:
1 parent
f0a9661f8e
commit
096ee32fa5
20 files changed
+6531
-29
No files matched your search
@@ -1,12 +1,13 @@
|
||||
"use client";
|
||||
// Discord sign-in (a basic account the first time, docs/music.md) and, from the account page, linking Discord to a
|
||||
// member's account. Discord sends people back to the API, which sends them on to these addresses on this site.
|
||||
import { useState } from "react";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { ErrorText } from "@/components/forms";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { authClient } from "@/lib/auth-client";
|
||||
|
||||
export function DiscordButton({ mode, next = "/" }: { mode: "sign-in" | "link"; next?: string }) {
|
||||
/** auto: start at once (a T5DE site asked for Discord sign-in). */
|
||||
export function DiscordButton({ mode, next = "/", auto = false }: { mode: "sign-in" | "link"; next?: string; auto?: boolean }) {
|
||||
const [pending, setPending] = useState(false);
|
||||
const [error, setError] = useState("");
|
||||
|
||||
@@ -29,6 +30,14 @@ export function DiscordButton({ mode, next = "/" }: { mode: "sign-in" | "link";
|
||||
}
|
||||
}
|
||||
|
||||
const started = useRef(false);
|
||||
useEffect(() => {
|
||||
if (!auto || started.current) return;
|
||||
started.current = true;
|
||||
void go();
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [auto]);
|
||||
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
<Button type="button" variant={mode === "link" ? "outline" : "default"} className={mode === "link" ? undefined : "w-full"} disabled={pending} onClick={() => void go()}>
|
||||
|
||||
Reference in new issue
Block a user