@@ -201,12 +201,13 @@ export async function deleteChat(roomId: number, uuid: number, inversion: boolea
201201 await chatCol . updateOne ( query , update )
202202}
203203
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 > {
205205 email = email . toLowerCase ( )
206206 const userInfo = new UserInfo ( email , password )
207207 if ( roles && roles . includes ( UserRole . Admin ) )
208208 userInfo . status = Status . Normal
209209 userInfo . roles = roles
210+ userInfo . remark = remark
210211 await userCol . insertOne ( userInfo )
211212 return userInfo
212213}
@@ -277,15 +278,15 @@ export async function updateUserStatus(userId: string, status: Status) {
277278 return await userCol . updateOne ( { _id : new ObjectId ( userId ) } , { $set : { status, verifyTime : new Date ( ) . toLocaleString ( ) } } )
278279}
279280
280- export async function updateUser ( userId : string , roles : UserRole [ ] , password : string ) {
281+ export async function updateUser ( userId : string , roles : UserRole [ ] , password : string , remark ?: string ) {
281282 const user = await getUserById ( userId )
282283 const query = { _id : new ObjectId ( userId ) }
283284 if ( user . password !== password && user . password ) {
284285 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 } } )
286287 }
287288 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 } } )
289290 }
290291}
291292
0 commit comments