feat: 完善员工门店软删除与密码管理
This commit is contained in:
@@ -83,7 +83,7 @@ export const authService = {
|
||||
user: AuthUser;
|
||||
payload: AuthJwtPayload;
|
||||
}> {
|
||||
const admin = await authRepository.findActiveByUsername(input.username);
|
||||
const admin = await authRepository.findByUsername(input.username);
|
||||
|
||||
if (admin) {
|
||||
const passwordMatched = await verifyPassword(
|
||||
@@ -95,6 +95,10 @@ export const authService = {
|
||||
throw unauthorized("用户名或密码错误");
|
||||
}
|
||||
|
||||
if (admin.status === "INACTIVE") {
|
||||
throw unauthorized("账号已被禁用");
|
||||
}
|
||||
|
||||
await authRepository.updateLastLoginAt(admin.id);
|
||||
|
||||
const user = await toAuthUser(admin);
|
||||
@@ -105,7 +109,7 @@ export const authService = {
|
||||
};
|
||||
}
|
||||
|
||||
const employee = await authRepository.findActiveEmployeeByPhone(
|
||||
const employee = await authRepository.findEmployeeByPhoneForLogin(
|
||||
input.username,
|
||||
);
|
||||
|
||||
@@ -122,6 +126,14 @@ export const authService = {
|
||||
throw unauthorized("用户名或密码错误");
|
||||
}
|
||||
|
||||
if (employee.status === "INACTIVE") {
|
||||
throw unauthorized("账号已被禁用");
|
||||
}
|
||||
|
||||
if (employee.storeStatus === "INACTIVE") {
|
||||
throw unauthorized("所属门店已被禁用");
|
||||
}
|
||||
|
||||
await authRepository.updateEmployeeLastLoginAt(employee.id);
|
||||
|
||||
const user = await toEmployeeAuthUser(employee);
|
||||
@@ -140,7 +152,7 @@ export const authService = {
|
||||
user: AuthUser;
|
||||
payload: AuthJwtPayload;
|
||||
}> {
|
||||
const employee = await authRepository.findActiveEmployeeByPhone(
|
||||
const employee = await authRepository.findEmployeeByPhoneForLogin(
|
||||
input.username,
|
||||
);
|
||||
|
||||
@@ -157,6 +169,14 @@ export const authService = {
|
||||
throw unauthorized("用户名或密码错误");
|
||||
}
|
||||
|
||||
if (employee.status === "INACTIVE") {
|
||||
throw unauthorized("账号已被禁用");
|
||||
}
|
||||
|
||||
if (employee.storeStatus === "INACTIVE") {
|
||||
throw unauthorized("所属门店已被禁用");
|
||||
}
|
||||
|
||||
await authRepository.updateEmployeeLastLoginAt(employee.id);
|
||||
|
||||
const user = await toEmployeeAuthUser(employee);
|
||||
|
||||
Reference in New Issue
Block a user