fix(iam): 合伙人登录双拦截——子账号status=DISABLED 与 主账号bindingStatus=PAUSED 均拒绝登录
CI / verify (push) Has been cancelled
CI / verify (push) Has been cancelled
This commit is contained in:
@@ -304,12 +304,34 @@ export class AuthService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 合伙人账号可登录态校验(统一闸门):
|
||||
* 1) 账号自身 status !== ACTIVE(DISABLED,含子账号)→ 拦截
|
||||
* 2) 所属主账号 bindingStatus !== ACTIVE(PAUSED,城市合伙人绑定暂停)→ 拦截
|
||||
* 子账号的绑定状态以父主账号为准。
|
||||
*/
|
||||
private async assertPartnerAccountActive(account: {
|
||||
id: bigint;
|
||||
status: string;
|
||||
isPrimary: number;
|
||||
bindingStatus?: string | null;
|
||||
}): Promise<void> {
|
||||
if (account.status !== 'ACTIVE') {
|
||||
throw new BadRequestException('该账号已暂停使用,请联系客服人员');
|
||||
}
|
||||
const primary =
|
||||
account.isPrimary === 1 ? account : await this.resolvePrimaryAccount(account.id);
|
||||
if (primary.bindingStatus && primary.bindingStatus !== 'ACTIVE') {
|
||||
throw new BadRequestException('该合伙人合作已暂停,请联系客服人员');
|
||||
}
|
||||
}
|
||||
|
||||
private async assertPartnerAccountByPhone(phone: string) {
|
||||
const account = await this.prisma.partnerAccount.findUnique({
|
||||
where: { phone },
|
||||
});
|
||||
if (!account) throw new BadRequestException('未找到合伙人账号');
|
||||
if (account.status !== 'ACTIVE') throw new BadRequestException('该账号已暂停使用,请联系客服人员');
|
||||
await this.assertPartnerAccountActive(account);
|
||||
return account;
|
||||
}
|
||||
|
||||
@@ -1061,7 +1083,7 @@ export class AuthService {
|
||||
where: { phone: normalizedPhone },
|
||||
});
|
||||
if (!account) throw new BadRequestException('未找到合伙人账号');
|
||||
if (account.status !== 'ACTIVE') throw new BadRequestException('该账号已暂停使用,请联系客服人员');
|
||||
await this.assertPartnerAccountActive(account);
|
||||
await this.syncTestFlagByPhone(normalizedPhone);
|
||||
const primary = await this.resolvePrimaryAccount(account.id);
|
||||
await this.prisma.partnerAccount.update({
|
||||
@@ -1723,9 +1745,7 @@ export class AuthService {
|
||||
throw new BadRequestException('首次登录请使用手机验证码,登录后将自动关联微信');
|
||||
}
|
||||
|
||||
if (account.status !== 'ACTIVE') {
|
||||
throw new BadRequestException('该账号已暂停使用,请联系客服人员');
|
||||
}
|
||||
await this.assertPartnerAccountActive(account);
|
||||
|
||||
account = await this.prisma.partnerAccount.update({
|
||||
where: { id: account.id },
|
||||
|
||||
Reference in New Issue
Block a user