File tree 1 file changed +4
-4
lines changed
apps/core/src/modules/user
1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ export class UserService {
49
49
async getMasterInfo ( getLoginIp = false ) {
50
50
const user = await this . userModel
51
51
. findOne ( )
52
- . select ( ` ${ getLoginIp ? ' +lastLoginIp' : '' } ` )
52
+ . select ( String ( getLoginIp ? ' +lastLoginIp' : '' ) )
53
53
. lean ( { virtuals : true } )
54
54
if ( ! user ) {
55
55
throw new BizException ( ErrorCodeEnum . MasterLost )
@@ -70,16 +70,16 @@ export class UserService {
70
70
}
71
71
72
72
async createMaster (
73
- model : Pick < UserModel , 'username' | 'name' | 'password' > &
73
+ model : Pick < UserModel , 'username' | 'name' | 'password' | 'mail' > &
74
74
Partial < Pick < UserModel , 'introduce' | 'avatar' | 'url' > > ,
75
75
) {
76
76
const hasMaster = await this . hasMaster ( )
77
77
// 禁止注册两个以上账户
78
78
if ( hasMaster ) {
79
79
throw new BadRequestException ( '我已经有一个主人了哦' )
80
80
}
81
-
82
- const res = await this . userModel . create ( { ...model } )
81
+ const avatar = model . avatar ?? getAvatar ( model . mail )
82
+ const res = await this . userModel . create ( { ...model , avatar } )
83
83
const token = await this . authService . jwtServicePublic . sign ( res . id )
84
84
return { token, username : res . username }
85
85
}
You can’t perform that action at this time.
0 commit comments