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

1142 rework unauth status codes #1148

Merged
Merged
Show file tree
Hide file tree
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
8 changes: 3 additions & 5 deletions api/policies/isLoggedIn.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
*/
module.exports = function (req, res, next) {
const { session, path } = req;
const { session } = req;
const userIsValid = session.usr && typeof session.usr === 'number';
// User is allowed, proceed to the next policy,
// or if this is the last policy, the controller
Expand All @@ -19,8 +19,6 @@ module.exports = function (req, res, next) {

// User is not allowed
// (default res.forbidden() behavior can be overridden in `config/403.js`)
return res.forbidden({
message: 'You must be logged in to perform this action.',
path,
});
return res.status(401)
.json('Please log in and try again');
};
2 changes: 1 addition & 1 deletion src/stores/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ export const useGameStore = defineStore('game', {
switch (jwres.statusCode) {
case 200:
return resolve(jwres);
case 403:
case 401:
authStore.mustReauthenticate = true;
return reject(jwres.body.message);
default:
Expand Down
Loading