@@ -201,12 +201,13 @@ export async function deleteChat(roomId: number, uuid: number, inversion: boolea
201
201
await chatCol . updateOne ( query , update )
202
202
}
203
203
204
- export async function createUser ( email : string , password : string , roles ?: UserRole [ ] ) : Promise < UserInfo > {
204
+ export async function createUser ( email : string , password : string , roles ?: UserRole [ ] , remark ?: string ) : Promise < UserInfo > {
205
205
email = email . toLowerCase ( )
206
206
const userInfo = new UserInfo ( email , password )
207
207
if ( roles && roles . includes ( UserRole . Admin ) )
208
208
userInfo . status = Status . Normal
209
209
userInfo . roles = roles
210
+ userInfo . remark = remark
210
211
await userCol . insertOne ( userInfo )
211
212
return userInfo
212
213
}
@@ -277,15 +278,15 @@ export async function updateUserStatus(userId: string, status: Status) {
277
278
return await userCol . updateOne ( { _id : new ObjectId ( userId ) } , { $set : { status, verifyTime : new Date ( ) . toLocaleString ( ) } } )
278
279
}
279
280
280
- export async function updateUser ( userId : string , roles : UserRole [ ] , password : string ) {
281
+ export async function updateUser ( userId : string , roles : UserRole [ ] , password : string , remark ?: string ) {
281
282
const user = await getUserById ( userId )
282
283
const query = { _id : new ObjectId ( userId ) }
283
284
if ( user . password !== password && user . password ) {
284
285
const newPassword = md5 ( password )
285
- return await userCol . updateOne ( query , { $set : { roles, verifyTime : new Date ( ) . toLocaleString ( ) , password : newPassword } } )
286
+ return await userCol . updateOne ( query , { $set : { roles, verifyTime : new Date ( ) . toLocaleString ( ) , password : newPassword , remark } } )
286
287
}
287
288
else {
288
- return await userCol . updateOne ( query , { $set : { roles, verifyTime : new Date ( ) . toLocaleString ( ) } } )
289
+ return await userCol . updateOne ( query , { $set : { roles, verifyTime : new Date ( ) . toLocaleString ( ) , remark } } )
289
290
}
290
291
}
291
292
0 commit comments