(auth)(bug) fix account switch validation might randomly switch to other authenticated account

This commit is contained in:
Andrea Vos 2023-07-14 01:22:00 +02:00
parent 990e8a8b0d
commit a37623f838
2 changed files with 7 additions and 3 deletions

View File

@ -59,7 +59,7 @@ export default {
async validateAccounts() {
for (let [username, {token}] of Object.entries(this.accounts)) {
try {
const user = await this.$axios.$get(`/user/current`, {
const user = await this.$axios.$get(`/user/current?no_cookie`, {
headers: {
authorization: 'Bearer ' + token,
},

View File

@ -298,7 +298,9 @@ router.use(handleErrorAsync(reloadUser));
export const loadCurrentUser = async (req, res) => {
if (!req.user) {
res.clearCookie('token');
if (req.query.no_cookie === undefined) {
res.clearCookie('token');
}
return res.json(null);
}
@ -312,7 +314,9 @@ export const loadCurrentUser = async (req, res) => {
delete dbUser.timesheets;
const token = await issueAuthentication(req.db, dbUser, false);
res.cookie('token', token, cookieSettings);
if (req.query.no_cookie === undefined) {
res.cookie('token', token, cookieSettings);
}
req.rawUser = jwt.validate(token);
req.user = req.rawUser;