mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-04 21:04:37 +08:00
fixed otp/password config update logic
Some checks failed
Runs E2E API Tests / build (20.x) (push) Has been cancelled
Runs E2E API Tests / build (22.x) (push) Has been cancelled
Lint & build / lint_and_build (20.x) (push) Has been cancelled
Lint & build / lint_and_build (22.x) (push) Has been cancelled
TOC Generator / TOC Generator (push) Has been cancelled
Some checks failed
Runs E2E API Tests / build (20.x) (push) Has been cancelled
Runs E2E API Tests / build (22.x) (push) Has been cancelled
Lint & build / lint_and_build (20.x) (push) Has been cancelled
Lint & build / lint_and_build (22.x) (push) Has been cancelled
TOC Generator / TOC Generator (push) Has been cancelled
This commit is contained in:
parent
eccebc2850
commit
29ae8a7e3e
@ -343,11 +343,11 @@ export const projectsCrudHandlers = createLazyProxy(() => createCrudHandlers(pro
|
||||
},
|
||||
});
|
||||
if (data.config?.credential_enabled !== undefined) {
|
||||
if (data.config.credential_enabled && !passwordAuth) {
|
||||
if (!passwordAuth) {
|
||||
await tx.authMethodConfig.create({
|
||||
data: {
|
||||
projectConfigId: oldProject.config.id,
|
||||
enabled: true,
|
||||
enabled: data.config.credential_enabled,
|
||||
passwordConfig: {
|
||||
create: {
|
||||
identifierType: "EMAIL",
|
||||
@ -355,7 +355,7 @@ export const projectsCrudHandlers = createLazyProxy(() => createCrudHandlers(pro
|
||||
},
|
||||
},
|
||||
});
|
||||
} else if (!data.config.credential_enabled && passwordAuth) {
|
||||
} else {
|
||||
await tx.authMethodConfig.update({
|
||||
where: {
|
||||
projectConfigId_id: {
|
||||
@ -364,7 +364,7 @@ export const projectsCrudHandlers = createLazyProxy(() => createCrudHandlers(pro
|
||||
},
|
||||
},
|
||||
data: {
|
||||
enabled: false,
|
||||
enabled: data.config.credential_enabled,
|
||||
},
|
||||
});
|
||||
}
|
||||
@ -377,11 +377,11 @@ export const projectsCrudHandlers = createLazyProxy(() => createCrudHandlers(pro
|
||||
},
|
||||
});
|
||||
if (data.config?.magic_link_enabled !== undefined) {
|
||||
if (data.config.magic_link_enabled && !otpAuth) {
|
||||
if (!otpAuth) {
|
||||
await tx.authMethodConfig.create({
|
||||
data: {
|
||||
projectConfigId: oldProject.config.id,
|
||||
enabled: true,
|
||||
enabled: data.config.magic_link_enabled,
|
||||
otpConfig: {
|
||||
create: {
|
||||
contactChannelType: "EMAIL",
|
||||
@ -389,7 +389,7 @@ export const projectsCrudHandlers = createLazyProxy(() => createCrudHandlers(pro
|
||||
},
|
||||
},
|
||||
});
|
||||
} else if (!data.config.magic_link_enabled && otpAuth) {
|
||||
} else {
|
||||
await tx.authMethodConfig.update({
|
||||
where: {
|
||||
projectConfigId_id: {
|
||||
@ -398,7 +398,7 @@ export const projectsCrudHandlers = createLazyProxy(() => createCrudHandlers(pro
|
||||
},
|
||||
},
|
||||
data: {
|
||||
enabled: false,
|
||||
enabled: data.config.magic_link_enabled,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@ -107,8 +107,8 @@ export function projectPrismaToCrud(
|
||||
.filter((provider): provider is Exclude<typeof provider, undefined> => !!provider)
|
||||
.sort((a, b) => a.id.localeCompare(b.id));
|
||||
|
||||
const passwordAuth = prisma.config.authMethodConfigs.find((config) => config.passwordConfig);
|
||||
const otpAuth = prisma.config.authMethodConfigs.find((config) => config.otpConfig);
|
||||
const passwordAuth = prisma.config.authMethodConfigs.find((config) => config.passwordConfig && config.enabled);
|
||||
const otpAuth = prisma.config.authMethodConfigs.find((config) => config.otpConfig && config.enabled);
|
||||
|
||||
return {
|
||||
id: prisma.id,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user