File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
apps/core/src/modules/user Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ export class UserService {
4949 async getMasterInfo ( getLoginIp = false ) {
5050 const user = await this . userModel
5151 . findOne ( )
52- . select ( ` ${ getLoginIp ? ' +lastLoginIp' : '' } ` )
52+ . select ( String ( getLoginIp ? ' +lastLoginIp' : '' ) )
5353 . lean ( { virtuals : true } )
5454 if ( ! user ) {
5555 throw new BizException ( ErrorCodeEnum . MasterLost )
@@ -70,16 +70,16 @@ export class UserService {
7070 }
7171
7272 async createMaster (
73- model : Pick < UserModel , 'username' | 'name' | 'password' > &
73+ model : Pick < UserModel , 'username' | 'name' | 'password' | 'mail' > &
7474 Partial < Pick < UserModel , 'introduce' | 'avatar' | 'url' > > ,
7575 ) {
7676 const hasMaster = await this . hasMaster ( )
7777 // 禁止注册两个以上账户
7878 if ( hasMaster ) {
7979 throw new BadRequestException ( '我已经有一个主人了哦' )
8080 }
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 } )
8383 const token = await this . authService . jwtServicePublic . sign ( res . id )
8484 return { token, username : res . username }
8585 }
You can’t perform that action at this time.
0 commit comments