Skip to content

Commit

Permalink
Moves call redirect to component from store
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Kokovin committed May 26, 2021
1 parent 93df4a8 commit 27b955f
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 19 deletions.
5 changes: 4 additions & 1 deletion src/components/PaySuperAuthForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@ export default {
}
this.$emit('loadingStart');
await this.authoriseWithLogin({
const url = await this.authoriseWithLogin({
email: this.email,
password: this.password,
remember: true,
});
if (url) {
this.$router.push(url);
}
this.$emit('loadingEnd');
},
},
Expand Down
5 changes: 4 additions & 1 deletion src/components/PaySuperAutoLoginForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ export default {
}
this.$emit('loadingStart');
await this.autoLogin({ previousLogin: this.previousLogin });
const url = await this.autoLogin({ previousLogin: this.previousLogin });
if (url) {
this.$router.push(url);
}
this.$emit('loadingEnd');
},
},
Expand Down
5 changes: 4 additions & 1 deletion src/components/PaySuperRegisterForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,14 @@ export default {
this.$emit('loadingStart');
await this.registerWithEmail({
const url = await this.registerWithEmail({
email: this.email,
password: this.password,
remember: true,
});
if (url) {
this.$router.push(url);
}
this.$emit('loadingEnd');
},
},
Expand Down
22 changes: 12 additions & 10 deletions src/store/AuthForm.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import axios from 'axios';
import { throttle } from 'lodash-es';
// import { throttle } from 'lodash-es';

function redirectToLogin(url) {
window.location.replace(url);
}
// function redirectToLogin(url) {
// window.location.replace(url);
// }

export default {
namespaced: true,
Expand All @@ -28,15 +28,15 @@ export default {
email,
password,
remember: (remember === '1'),
}, {
headers: { 'If-Unmodified-Since': (new Date()).toUTCString() },
});
const throttled = throttle(redirectToLogin(data.url), 100);
throttled();
return data.url;
// const throttled = throttle(redirectToLogin(data.url), 100);
// throttled();
} catch (error) {
if (error.response) {
commit('authError', error.response.data.error_message);
}
return '';
}
},

Expand All @@ -47,12 +47,14 @@ export default {
challenge: rootState.challenge,
previousLogin,
});
const throttled = throttle(redirectToLogin(data.url), 100);
throttled();
return data.url;
// const throttled = throttle(redirectToLogin(data.url), 100);
// throttled();
} catch (error) {
if (error.response) {
commit('authError', error.response.data.error_message);
}
return '';
}
},

Expand Down
14 changes: 8 additions & 6 deletions src/store/RegisterForm.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import axios from 'axios';
import { throttle } from 'lodash-es';
// import { throttle } from 'lodash-es';

function redirectToLogin(url) {
window.location.replace(url);
}
// function redirectToLogin(url) {
// window.location.replace(url);
// }

export default {
namespaced: true,
Expand Down Expand Up @@ -31,12 +31,14 @@ export default {
password,
remember: (remember === '1'),
});
const throttled = throttle(redirectToLogin(data.url), 100);
throttled();
return data.url;
// const throttled = throttle(redirectToLogin(data.url), 100);
// throttled();
} catch (error) {
if (error.response) {
commit('registerError', error.response.data.error_message);
}
return '';
}
},

Expand Down

0 comments on commit 27b955f

Please sign in to comment.