Skip to content

Commit

Permalink
Fix autologin redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgeny Talagaev committed Oct 18, 2023
1 parent c902ad2 commit d0f0372
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
9 changes: 6 additions & 3 deletions src/controllers/AuthController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ class AuthController {
return;
}

Store.set('error', res.response);
const { reason } = res.response;
Store.set('error', reason);
})
.catch((error) => {
console.error(`${error}`);
Expand All @@ -31,14 +32,16 @@ class AuthController {
return;
}

if (res.response === 'User already in system') {
const { reason } = res.response;

if (reason === 'User already in system') {
sessionStorage.setItem("inSystem", "true");
router.go('/messenger');

return;
}

Store.set('error', res.response);
Store.set('error', reason);
})
.catch((error) => {
console.error(`${error}`);
Expand Down
12 changes: 8 additions & 4 deletions src/controllers/ChatsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class ChatsController {
return;
}

Store.set('error', res.response);
const { reason } = res.response;
Store.set('error', reason);
})
.catch((error) => {
console.error(`${error}`);
Expand All @@ -36,7 +37,8 @@ class ChatsController {
return;
}

Store.set('error', res.response);
const { reason } = res.response;
Store.set('error', reason);
})
.catch((error) => {
console.error(`${error}`);
Expand All @@ -61,7 +63,8 @@ class ChatsController {
return;
}

Store.set('error', res.response);
const { reason } = res.response;
Store.set('error', reason);
})
.catch((error) => {
console.error(`${error}`);
Expand Down Expand Up @@ -129,7 +132,8 @@ class ChatsController {
return;
}

Store.set('error', res.response);
const { reason } = res.response;
Store.set('error', reason);
})
.catch((error) => {
console.error(`${error}`);
Expand Down
12 changes: 8 additions & 4 deletions src/controllers/UsersController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ class UsersController {
return;
}

Store.set('error', res.response);
const { reason } = res.response;
Store.set('error', reason);
})
.catch((error) => {
console.error(`${error}`);
Expand All @@ -33,7 +34,8 @@ class UsersController {
return;
}

Store.set('error', res.response);
const { reason } = res.response;
Store.set('error', reason);
})
.catch((error) => {
console.error(`${error}`);
Expand All @@ -47,7 +49,8 @@ class UsersController {
return;
}

Store.set('error', res.response);
const { reason } = res.response;
Store.set('error', reason);
})
.catch((error) => {
console.error(`${error}`);
Expand All @@ -61,7 +64,8 @@ class UsersController {
return res.response;
}

Store.set('error', res.response);
const { reason } = res.response;
Store.set('error', reason);
}

public async request(id: number) {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class HTTP implements IHTTP {
try {
response = JSON.parse(xhr.responseText);
} catch (error) {
console.error(error);
// Send error to logger
}

const data = {
Expand Down

0 comments on commit d0f0372

Please sign in to comment.