Skip to content

Commit

Permalink
Merge pull request #73 from webitel/fix/redirect-after-login
Browse files Browse the repository at this point in the history
fix: redirect when successful authorization[WTEL-3405
  • Loading branch information
Lera24 authored May 17, 2024
2 parents 5d9fe0d + 5520f1e commit aed1d87
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/store/modules/auth/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@ const actions = {
SUBMIT_AUTH: async (context, action) => {
let accessToken;

if(action === 'login') {
if(context.state.sessionId) {
accessToken = await context.dispatch('LOGIN_2FA');
}
accessToken = await context.dispatch('LOGIN');
} else if(action === 'register') {
accessToken = await context.dispatch('REGISTER');
} else throw new Error(`Invalid action: ${action}`);
switch (action) {
case 'login':
accessToken = await context.dispatch(context.state.sessionId ? 'LOGIN_2FA' : 'LOGIN');
break;
case 'register':
accessToken = await context.dispatch('REGISTER');
break;
default:
throw new Error(`Invalid action: ${action}`);
}

return context.dispatch('ON_AUTH_SUCCESS', { accessToken });
},
Expand Down

0 comments on commit aed1d87

Please sign in to comment.