-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd056f0
commit 32c061f
Showing
10 changed files
with
116 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Logger } from "../../../singleton/logger"; | ||
const log = Logger.getLogger().child({ from: "user/logout.get" }); | ||
|
||
import { Request, Response } from "express"; | ||
|
||
import { errorMessages, statusCodes } from "../../../utils/http-status"; | ||
import { ErrorResponse, SuccessResponse } from "../../../utils/response"; | ||
import GET_Logout from "./logout.get"; | ||
import UserModel from "../../../model/mongo/user"; | ||
import { flushUserInfoFromRedis } from "../../../model/oauth"; | ||
|
||
const GET_LogoutAll = async (req: Request, res: Response) => { | ||
try { | ||
if (!res.locals.oauth) { | ||
res.status(statusCodes.success).json(new SuccessResponse()); | ||
return; | ||
} | ||
const userId = res.locals.oauth.token.user._id; | ||
await UserModel.updateOne({ _id: userId }, { $set: { globalLogoutAt: new Date().toISOString() } }); | ||
await GET_Logout(req, res); | ||
flushUserInfoFromRedis([userId]); | ||
} catch (err) { | ||
log.error(err); | ||
return res.status(statusCodes.internalError).json(new ErrorResponse(errorMessages.internalError)); | ||
} | ||
}; | ||
|
||
export default GET_LogoutAll; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters