aboutsummaryrefslogtreecommitdiff
path: root/src/site/pages/dashboard/account.vue
diff options
context:
space:
mode:
authorPitu <[email protected]>2019-04-24 08:36:28 +0000
committerPitu <[email protected]>2019-04-24 08:36:28 +0000
commit3bd8d119ba88e940932eca50be406d50d73040fb (patch)
tree9d24cdfc1edc53cce6670ffabb60597636571ecd /src/site/pages/dashboard/account.vue
parentGet rid of the icons altogether in a future commit (diff)
downloadhost.fuwn.me-3bd8d119ba88e940932eca50be406d50d73040fb.tar.xz
host.fuwn.me-3bd8d119ba88e940932eca50be406d50d73040fb.zip
Refactor a bit since we globally catch API exceptions
Diffstat (limited to 'src/site/pages/dashboard/account.vue')
-rw-r--r--src/site/pages/dashboard/account.vue52
1 files changed, 26 insertions, 26 deletions
diff --git a/src/site/pages/dashboard/account.vue b/src/site/pages/dashboard/account.vue
index 3ccbc31..3aa103f 100644
--- a/src/site/pages/dashboard/account.vue
+++ b/src/site/pages/dashboard/account.vue
@@ -108,27 +108,31 @@ export default {
},
methods: {
async getUserSetttings() {
- try {
- const response = await this.$axios.$get(`users/me`);
- this.user = response.user;
- } catch (error) {
- this.$onPromiseError(error);
- }
+ const response = await this.$axios.$get(`users/me`);
+ this.user = response.user;
},
async changePassword() {
- if (!this.user.password || !this.user.newPassword || !this.user.reNewPassword) return this.$showToast('One or more fields are missing', true);
- if (this.user.newPassword !== this.user.reNewPassword) return this.$showToast('Passwords don\'t match', true);
-
- try {
- const response = await this.$axios.$post(`user/password/change`,
- {
- password: this.user.password,
- newPassword: this.user.newPassword
- });
- this.$toast.open(response.message);
- } catch (error) {
- this.$onPromiseError(error);
+ if (!this.user.password || !this.user.newPassword || !this.user.reNewPassword) {
+ this.$store.dispatch('alert', {
+ text: 'One or more fields are missing',
+ error: true
+ });
+ return;
+ }
+ if (this.user.newPassword !== this.user.reNewPassword) {
+ this.$store.dispatch('alert', {
+ text: 'Passwords don\'t match',
+ error: true
+ });
+ return;
}
+
+ const response = await this.$axios.$post(`user/password/change`,
+ {
+ password: this.user.password,
+ newPassword: this.user.newPassword
+ });
+ this.$toast.open(response.message);
},
promptNewAPIKey() {
this.$dialog.confirm({
@@ -138,14 +142,10 @@ export default {
});
},
async requestNewAPIKey() {
- try {
- const response = await this.$axios.$post(`user/apikey/change`);
- this.user.apiKey = response.apiKey;
- this.$forceUpdate();
- this.$toast.open(response.message);
- } catch (error) {
- this.$onPromiseError(error);
- }
+ const response = await this.$axios.$post(`user/apikey/change`);
+ this.user.apiKey = response.apiKey;
+ this.$forceUpdate();
+ this.$toast.open(response.message);
}
}
};