mirror of
https://github.com/gethomepage/homepage.git
synced 2026-02-07 08:20:53 +08:00
Normalize credentials provider id and signin lookup
This commit is contained in:
@@ -54,8 +54,8 @@ describe("pages/api/auth/[...nextauth]", () => {
|
||||
const mod = await import("pages/api/auth/[...nextauth]");
|
||||
const [provider] = mod.default.options.providers;
|
||||
|
||||
expect(provider.id).toBe("homepage-password");
|
||||
expect(provider.name).toBe("Password");
|
||||
expect(provider.id).toBe("credentials");
|
||||
expect(provider.name).toBe("Credentials");
|
||||
expect(provider.type).toBe("credentials");
|
||||
expect(typeof provider.authorize).toBe("function");
|
||||
});
|
||||
|
||||
@@ -67,7 +67,6 @@ if (authEnabled) {
|
||||
} else {
|
||||
providers = [
|
||||
CredentialsProvider({
|
||||
id: "homepage-password",
|
||||
name: "Password",
|
||||
credentials: {
|
||||
password: { label: "Password", type: "password" },
|
||||
|
||||
@@ -102,7 +102,10 @@ export default function SignIn({ providers, settings }) {
|
||||
);
|
||||
}
|
||||
|
||||
const hasPasswordProvider = Boolean(providers?.["homepage-password"]);
|
||||
const passwordProvider = providers
|
||||
? Object.values(providers).find((provider) => provider.type === "credentials")
|
||||
: null;
|
||||
const hasPasswordProvider = Boolean(passwordProvider);
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -147,7 +150,7 @@ export default function SignIn({ providers, settings }) {
|
||||
className="space-y-3"
|
||||
onSubmit={async (event) => {
|
||||
event.preventDefault();
|
||||
await signIn("homepage-password", {
|
||||
await signIn(passwordProvider?.id ?? "credentials", {
|
||||
redirect: true,
|
||||
callbackUrl,
|
||||
password,
|
||||
|
||||
Reference in New Issue
Block a user