Skip to content

Commit 0c2b2b4

Browse files
committed
Get account pages working
1 parent 11a70b0 commit 0c2b2b4

File tree

10 files changed

+417
-416
lines changed

10 files changed

+417
-416
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import Vue from 'vue';
2+
import Navigation from "../core/Navigation";
3+
import Flash from "../Flash";
4+
import UpdateEmail from "./account/UpdateEmail";
5+
import ChangePassword from "./account/ChangePassword";
6+
import TwoFactorAuthentication from "./account/TwoFactorAuthentication";
7+
import Modal from "../core/Modal";
8+
9+
export default Vue.component('account', {
10+
components: {
11+
TwoFactorAuthentication,
12+
Modal,
13+
ChangePassword,
14+
UpdateEmail,
15+
Flash,
16+
Navigation
17+
},
18+
19+
data: function () {
20+
return {
21+
modalVisible: false,
22+
};
23+
},
24+
25+
methods: {
26+
openModal: function () {
27+
this.modalVisible = true;
28+
window.events.$emit('two_factor:open');
29+
},
30+
},
31+
32+
template: `
33+
<div>
34+
<navigation/>
35+
<div class="container animate fadein mt-2 sm:mt-6">
36+
<modal :show="modalVisible" v-on:close="modalVisible = false">
37+
<TwoFactorAuthentication v-on:close="modalVisible = false"/>
38+
</modal>
39+
<flash container="mt-2 sm:mt-6 mb-2"/>
40+
<div class="flex flex-wrap">
41+
<div class="w-full md:w-1/2">
42+
<div class="sm:m-4 md:ml-0">
43+
<update-email class="mb-4 sm:mb-8"/>
44+
<div class="content-box text-center mb-4 sm:mb-0">
45+
<button class="btn btn-green btn-sm" type="submit" id="grid-open-two-factor-modal"
46+
v-on:click="openModal"
47+
>Configure 2-Factor Authentication</button>
48+
</div>
49+
</div>
50+
</div>
51+
<div class="w-full md:w-1/2">
52+
<change-password class="sm:m-4 md:mr-0"/>
53+
</div>
54+
</div>
55+
</div>
56+
</div>
57+
`,
58+
})

resources/assets/scripts/components/dashboard/Account.vue

Lines changed: 0 additions & 51 deletions
This file was deleted.
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
import Vue from 'vue';
2+
import { isObject } from 'lodash';
3+
import {AxiosError} from "axios";
4+
5+
export default Vue.component('change-password', {
6+
data: function () {
7+
return {
8+
current: '',
9+
newPassword: '',
10+
confirmNew: '',
11+
};
12+
},
13+
14+
methods: {
15+
submitForm: function () {
16+
this.$flash.clear();
17+
this.$validator.pause();
18+
19+
window.axios.put(this.route('api.client.account.update-password'), {
20+
current_password: this.current,
21+
password: this.newPassword,
22+
password_confirmation: this.confirmNew,
23+
})
24+
.then(() => this.current = '')
25+
.then(() => {
26+
this.newPassword = '';
27+
this.confirmNew = '';
28+
29+
this.$flash.success(this.$t('dashboard.account.password.updated'));
30+
})
31+
.catch((err: AxiosError) => {
32+
if (!err.response) {
33+
this.$flash.error('There was an error with the network request. Please try again.');
34+
console.error(err);
35+
return;
36+
}
37+
38+
const response = err.response;
39+
if (response.data && isObject(response.data.errors)) {
40+
response.data.errors.forEach((error: any) => {
41+
this.$flash.error(error.detail);
42+
});
43+
}
44+
})
45+
.then(() => {
46+
this.$validator.resume();
47+
(this.$refs.current as HTMLElement).focus();
48+
})
49+
}
50+
},
51+
52+
template: `
53+
<div id="change-password-container" :class>
54+
<form method="post" v-on:submit.prevent="submitForm">
55+
<div class="content-box">
56+
<h2 class="mb-6 text-grey-darkest font-medium">{{ $t('dashboard.account.password.title') }}</h2>
57+
<div class="mt-6">
58+
<label for="grid-password-current" class="input-label">{{ $t('strings.password') }}</label>
59+
<input id="grid-password-current" name="current_password" type="password" class="input" required
60+
ref="current"
61+
v-model="current"
62+
>
63+
</div>
64+
<div class="mt-6">
65+
<label for="grid-password-new" class="input-label">{{ $t('strings.new_password') }}</label>
66+
<input id="grid-password-new" name="password" type="password" class="input" required
67+
:class="{ error: errors.has('password') }"
68+
v-model="newPassword"
69+
v-validate="'min:8'"
70+
>
71+
<p class="input-help error" v-show="errors.has('password')">{{ errors.first('password') }}</p>
72+
<p class="input-help">{{ $t('dashboard.account.password.requirements') }}</p>
73+
</div>
74+
<div class="mt-6">
75+
<label for="grid-password-new-confirm" class="input-label">{{ $t('strings.confirm_password') }}</label>
76+
<input id="grid-password-new-confirm" name="password_confirmation" type="password" class="input" required
77+
:class="{ error: errors.has('password_confirmation') }"
78+
v-model="confirmNew"
79+
v-validate="{is: newPassword}"
80+
data-vv-as="password"
81+
>
82+
<p class="input-help error" v-show="errors.has('password_confirmation')">{{ errors.first('password_confirmation') }}</p>
83+
</div>
84+
<div class="mt-6 text-right">
85+
<button class="btn btn-blue btn-sm text-right" type="submit">{{ $t('strings.save') }}</button>
86+
</div>
87+
</div>
88+
</form>
89+
</div>
90+
`,
91+
});

resources/assets/scripts/components/dashboard/account/ChangePassword.vue

Lines changed: 0 additions & 91 deletions
This file was deleted.

0 commit comments

Comments
 (0)