1
0
mirror of https://github.com/sasjs/server.git synced 2026-01-11 08:20:04 +00:00

feat: JWT saved in DB + logout api added

This commit is contained in:
Saad Jutt
2021-11-03 14:56:04 +05:00
parent d6aeb378de
commit 46c5a75ac4
15 changed files with 338 additions and 149 deletions

View File

@@ -0,0 +1,14 @@
import User from '../model/User'
export const removeTokensInDB = async (username: string, client_id: string) => {
const user = await User.findOne({ username })
const tokenObjIndex = user.tokens.findIndex(
(tokenObj: any) => tokenObj.clientid === client_id
)
if (tokenObjIndex > -1) {
user.tokens.splice(tokenObjIndex, 1)
await user.save()
}
}