mirror of
https://github.com/sasjs/server.git
synced 2026-01-07 06:30:06 +00:00
chore(merge): Merge branch 'master' into authentication-with-jwt
This commit is contained in:
15
api/src/utils/removeTokensInDB.ts
Normal file
15
api/src/utils/removeTokensInDB.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import User from '../model/User'
|
||||
|
||||
export const removeTokensInDB = async (userId: number, clientId: string) => {
|
||||
const user = await User.findOne({ id: userId })
|
||||
if (!user) return
|
||||
|
||||
const tokenObjIndex = user.tokens.findIndex(
|
||||
(tokenObj: any) => tokenObj.clientId === clientId
|
||||
)
|
||||
|
||||
if (tokenObjIndex > -1) {
|
||||
user.tokens.splice(tokenObjIndex, 1)
|
||||
await user.save()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user