mirror of
https://github.com/certd/certd.git
synced 2026-04-14 12:30:54 +08:00
fix: 修复用户删除后,用相同的oauth授权登录报错用户不存在的问题
https://github.com/certd/certd/issues/603
This commit is contained in:
@@ -242,7 +242,9 @@ export class LoginService {
|
||||
}
|
||||
const info = await this.userService.findOne({id: oauthBound.userId});
|
||||
if (info == null) {
|
||||
throw new CommonException('用户不存在');
|
||||
// 用户已被删除,删除此oauth绑定
|
||||
await this.oauthBoundService.delete([oauthBound.id]);
|
||||
return null
|
||||
}
|
||||
return this.generateToken(info);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import { RandomUtil } from '../../../../utils/random.js';
|
||||
import dayjs from 'dayjs';
|
||||
import { DbAdapter } from '../../../db/index.js';
|
||||
import { simpleNanoId, utils } from '@certd/basic';
|
||||
import { OauthBoundService } from '../../../login/service/oauth-bound-service.js';
|
||||
|
||||
export type RegisterType = 'username' | 'mobile' | 'email';
|
||||
export type ForgotPasswordType = 'mobile' | 'email';
|
||||
@@ -42,6 +43,10 @@ export class UserService extends BaseService<UserEntity> {
|
||||
@Inject()
|
||||
dbAdapter: DbAdapter;
|
||||
|
||||
@Inject()
|
||||
oauthBoundService: OauthBoundService;
|
||||
|
||||
|
||||
//@ts-ignore
|
||||
getRepository() {
|
||||
return this.repository;
|
||||
@@ -311,6 +316,9 @@ export class UserService extends BaseService<UserEntity> {
|
||||
throw new CommonException('不能删除管理员');
|
||||
}
|
||||
await super.delete(ids);
|
||||
await this.oauthBoundService.deleteWhere({
|
||||
userId: In(ids),
|
||||
});
|
||||
}
|
||||
|
||||
async isAdmin(userId: any) {
|
||||
|
||||
Reference in New Issue
Block a user