Skip to content

Commit

Permalink
Merge pull request #78 from webitel/hotfix/back-in-prev-step-when-error
Browse files Browse the repository at this point in the history
hotfix: back in prev step in login when error[WTEL-4563]
  • Loading branch information
Lera24 authored May 22, 2024
2 parents 36b5ffd + 776c0d1 commit 2e0aa6e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/api/instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ instance.interceptors.response.use(
type: 'error',
text: error.detail || error.response.data.detail,
});
}
return Promise.reject(error.response.data);
}
return Promise.reject(error);
},
);

Expand Down
16 changes: 15 additions & 1 deletion src/components/auth/login/the-login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ import SecondStep from '../login/steps/the-login-second-step.vue';
import ThirdStep from './steps/the-login-third-step.vue';
export default {
name: 'the-login',
props: {
isBackPrevStep: {
type: Boolean,
default: false,
},
},
data: () => ({
activeStep: 1,
isFirstStepSubmitting: false,
Expand Down Expand Up @@ -91,7 +97,7 @@ export default {
this.activeStep = this.activeStep - 1;
}
if (this.activeStep === 3) {
if (this.activeStep === 2 && this.enabledTfa) {
this.setProp({ prop: 'totp', value: '' });
}
},
Expand Down Expand Up @@ -128,6 +134,14 @@ export default {
this.resetState();
},
watch: {
isBackPrevStep: {
handler(value) {
if(value && this.activeStep === 3) this.backPrevStep();
}
}
}
};
</script>

Expand Down
11 changes: 10 additions & 1 deletion src/components/auth/the-auth.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
<h1 class="auth-tabs-title">{{ currentTab.title }}</h1>
<component
:is="currentTab.value"
:is-back-prev-step="isBackPrevStepInLogin"
@change-tab="currentTab = $event"
@submit="submitAuth(currentTab.value)"
@submit="authorization(currentTab.value)"
/>
</div>
</section>
Expand Down Expand Up @@ -83,6 +84,7 @@ export default {
new Pagination({ type: 'bullet' }),
new AutoPlay({ duration: 9000, stopOnHover: false }),
],
isBackPrevStepInLogin: false,
}),
computed: {
...mapState('appearance', {
Expand Down Expand Up @@ -113,6 +115,13 @@ export default {
const registerTab = this.tabs.find(({ value }) => value === 'register');
this.currentTab = this.$route.query.reset ? registerTab : loginTab;
},
async authorization(tab) {
try {
await this.submitAuth(tab)
} catch (err) {
if(tab === 'login' && err.code === 400) this.isBackPrevStepInLogin = true;
}
}
},
created() {
this.setInnitialTab();
Expand Down

0 comments on commit 2e0aa6e

Please sign in to comment.