超管用户登录;
代码核销功能
This commit is contained in:
@@ -19,6 +19,7 @@ import type { SmsActorRef } from '../../integrations/sms/sms.interface';
|
||||
import { SmsCodeStore } from '../../integrations/sms/sms-code.store';
|
||||
import type { IWechatProvider } from '../../integrations/wechat/wechat.interface';
|
||||
import { serializeBigInt } from '../../common/decorators/current-user.decorator';
|
||||
import { verifyPassword } from '../../common/crypto/password.util';
|
||||
import { AnalyticsService } from '../analytics/analytics.service';
|
||||
import { UserAddressService } from './user-address.service';
|
||||
|
||||
@@ -450,6 +451,30 @@ export class AuthService {
|
||||
});
|
||||
}
|
||||
|
||||
async loginHqPassword(loginName: string, password: string, clientApp: ClientApp) {
|
||||
const normalizedLogin = loginName.trim();
|
||||
if (!normalizedLogin) throw new BadRequestException('请输入账号');
|
||||
const account = await this.prisma.hqAccount.findUnique({
|
||||
where: { loginName: normalizedLogin },
|
||||
});
|
||||
if (!account?.passwordHash) throw new BadRequestException('账号或密码错误');
|
||||
if (account.status !== 'ACTIVE') throw new BadRequestException('账号已停用');
|
||||
if (!verifyPassword(password, account.passwordHash)) {
|
||||
throw new BadRequestException('账号或密码错误');
|
||||
}
|
||||
await this.prisma.hqAccount.update({
|
||||
where: { id: account.id },
|
||||
data: { lastLoginAt: new Date() },
|
||||
});
|
||||
return this.issueToken('HQ', account.id, clientApp, false, undefined, undefined, undefined, undefined, {
|
||||
id: account.id.toString(),
|
||||
phone: account.phone,
|
||||
name: account.name,
|
||||
adminRole: account.adminRole,
|
||||
status: account.status,
|
||||
});
|
||||
}
|
||||
|
||||
async getMe(actorType: string, actorId: bigint) {
|
||||
if (actorType === 'USER') {
|
||||
const user = await this.assertActiveUser(actorId);
|
||||
|
||||
Reference in New Issue
Block a user