chore: initial commit
This commit is contained in:
19
src/services/users/signout/delete.ts
Normal file
19
src/services/users/signout/delete.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import { Request, Response, Router } from 'express'
|
||||
|
||||
import { authenticateUser } from '../../../tools/middlewares/authenticateUser'
|
||||
import { ForbiddenError } from '../../../tools/errors/ForbiddenError'
|
||||
import { deleteEveryRefreshTokens } from '../__utils__/deleteEveryRefreshTokens'
|
||||
|
||||
export const signoutEveryDevicesRouter = Router()
|
||||
|
||||
signoutEveryDevicesRouter.delete(
|
||||
'/users/signout',
|
||||
authenticateUser,
|
||||
async (req: Request, res: Response) => {
|
||||
if (req.user == null) {
|
||||
throw new ForbiddenError()
|
||||
}
|
||||
await deleteEveryRefreshTokens(req.user.current.id)
|
||||
res.status(200).json({})
|
||||
}
|
||||
)
|
Reference in New Issue
Block a user