Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server: reduce the number of redis reads necessary for each request #1577

Merged
merged 1 commit into from
Mar 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion server/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
req.token = req.cookies.token;
}

if (!req.token || !(await tokens.validate(req.token))) {
if (!req.token) {
res.status(400).json({
success: false,
error: {
Expand All @@ -70,6 +70,16 @@
}

req.ottsession = await tokens.getSessionInfo(req.token);
if (!req.ottsession) {
res.status(401).json({
success: false,
error: {
name: "MissingToken",
message: "Missing valid auth token. Get a token from /api/auth/grant first.",
},
});
return;

Check warning on line 81 in server/auth/index.ts

View check run for this annotation

Codecov / codecov/patch

server/auth/index.ts#L74-L81

Added lines #L74 - L81 were not covered by tests
}
if (req.ottsession && req.ottsession.isLoggedIn) {
try {
req.user = await usermanager.getUser({ id: req.ottsession.user_id });
Expand Down
Loading