- auth: actionDeleteAccount 改用 service+repo,forgot-password 完整三层实现 - card: serviceCheckCardOwnership 替代直接调用 repository - deck: 移除 service 层的 use server 指令 - dictionary: 数据转换逻辑从 repository 移到 service - ocr: 认证移到 action 层,跨模块调用改用 service - translator: genIPA/genLanguage 改用 service 层
35 lines
991 B
TypeScript
35 lines
991 B
TypeScript
import { auth } from "@/auth";
|
|
import { createLogger } from "@/lib/logger";
|
|
import { repoFindUserByEmail } from "./forgot-password-repository";
|
|
import {
|
|
ServiceInputRequestPasswordReset,
|
|
ServiceOutputRequestPasswordReset
|
|
} from "./forgot-password-service-dto";
|
|
|
|
const log = createLogger("forgot-password-service");
|
|
|
|
export async function serviceRequestPasswordReset(dto: ServiceInputRequestPasswordReset): Promise<ServiceOutputRequestPasswordReset> {
|
|
log.info("Processing password reset request", { email: dto.email });
|
|
|
|
const user = await repoFindUserByEmail({ email: dto.email });
|
|
|
|
if (!user) {
|
|
return {
|
|
success: false,
|
|
message: "该邮箱未注册",
|
|
};
|
|
}
|
|
|
|
await auth.api.requestPasswordReset({
|
|
body: {
|
|
email: dto.email,
|
|
redirectTo: "/reset-password",
|
|
},
|
|
});
|
|
|
|
return {
|
|
success: true,
|
|
message: "重置密码邮件已发送,请检查您的邮箱",
|
|
};
|
|
}
|