mirror of
https://github.com/sasjs/server.git
synced 2025-12-11 03:34:35 +00:00
15 lines
366 B
TypeScript
15 lines
366 B
TypeScript
import User from '../model/User'
|
|
|
|
export const removeTokensInDB = async (username: string, clientId: string) => {
|
|
const user = await User.findOne({ username })
|
|
|
|
const tokenObjIndex = user.tokens.findIndex(
|
|
(tokenObj: any) => tokenObj.clientId === clientId
|
|
)
|
|
|
|
if (tokenObjIndex > -1) {
|
|
user.tokens.splice(tokenObjIndex, 1)
|
|
await user.save()
|
|
}
|
|
}
|