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 mod = await import("pages/api/auth/[...nextauth]");
|
||||||
const [provider] = mod.default.options.providers;
|
const [provider] = mod.default.options.providers;
|
||||||
|
|
||||||
expect(provider.id).toBe("homepage-password");
|
expect(provider.id).toBe("credentials");
|
||||||
expect(provider.name).toBe("Password");
|
expect(provider.name).toBe("Credentials");
|
||||||
expect(provider.type).toBe("credentials");
|
expect(provider.type).toBe("credentials");
|
||||||
expect(typeof provider.authorize).toBe("function");
|
expect(typeof provider.authorize).toBe("function");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -67,7 +67,6 @@ if (authEnabled) {
|
|||||||
} else {
|
} else {
|
||||||
providers = [
|
providers = [
|
||||||
CredentialsProvider({
|
CredentialsProvider({
|
||||||
id: "homepage-password",
|
|
||||||
name: "Password",
|
name: "Password",
|
||||||
credentials: {
|
credentials: {
|
||||||
password: { label: "Password", type: "password" },
|
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 (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -147,7 +150,7 @@ export default function SignIn({ providers, settings }) {
|
|||||||
className="space-y-3"
|
className="space-y-3"
|
||||||
onSubmit={async (event) => {
|
onSubmit={async (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
await signIn("homepage-password", {
|
await signIn(passwordProvider?.id ?? "credentials", {
|
||||||
redirect: true,
|
redirect: true,
|
||||||
callbackUrl,
|
callbackUrl,
|
||||||
password,
|
password,
|
||||||
|
|||||||
Reference in New Issue
Block a user