mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-08-17 17:11:06 +02:00
Add Password and Profile update
This commit is contained in:
@@ -67,7 +67,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="content has-text-centered">
|
||||
{{ $t('auth.hello', {username: username}) }} <a class="has-text-grey" @click="logout">{{ $t('auth.sign_out') }}</a>
|
||||
{{ $t('auth.hello', {username: username}) }} <router-link :to="{ name: 'profile' }" class="has-text-grey">{{ $t('commons.profile') }}</router-link> - <a class="has-text-grey" @click="logout">{{ $t('auth.sign_out') }}</a>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
|
94
resources/js/views/auth/password/Update.vue
Normal file
94
resources/js/views/auth/password/Update.vue
Normal file
@@ -0,0 +1,94 @@
|
||||
<template>
|
||||
<div class="section">
|
||||
<div class="columns is-mobile is-centered">
|
||||
<div class="column is-two-thirds-tablet is-half-desktop is-one-third-widescreen is-one-quarter-fullhd">
|
||||
<h1 class="title">{{ $t('auth.forms.change_password') }}</h1>
|
||||
<form @submit.prevent="handleSubmit" @keydown="form.onKeydown($event)">
|
||||
<div class="field">
|
||||
<label class="label">{{ $t('auth.forms.current_password') }}</label>
|
||||
<div class="control">
|
||||
<input id="currentPassword" type="password" class="input" v-model="form.currentPassword" />
|
||||
</div>
|
||||
<field-error :form="form" field="currentPassword" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label">{{ $t('auth.forms.new_password') }}</label>
|
||||
<div class="control">
|
||||
<input id="password" type="password" class="input" v-model="form.password" />
|
||||
</div>
|
||||
<field-error :form="form" field="password" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label">{{ $t('auth.forms.confirm_password') }}</label>
|
||||
<div class="control">
|
||||
<input id="password_confirmation" type="password" class="input" v-model="form.password_confirmation" />
|
||||
</div>
|
||||
<field-error :form="form" field="password_confirmation" />
|
||||
</div>
|
||||
<div class="field is-grouped">
|
||||
<div class="control">
|
||||
<v-button :isLoading="form.isBusy" >{{ $t('auth.forms.change_password') }}</v-button>
|
||||
</div>
|
||||
<div class="control">
|
||||
<router-link :to="{ name: 'profile' }" class="button is-text">{{ $t('commons.cancel') }}</router-link>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field" v-if="errorMessage">
|
||||
<span class="tag is-danger">
|
||||
{{ errorMessage }}
|
||||
</span>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="columns is-mobile is-centered" v-if="response">
|
||||
<div class="has-text-link column is-two-thirds-tablet is-half-desktop is-one-third-widescreen is-one-quarter-fullhd">
|
||||
<span class="tag is-success">
|
||||
{{ response }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import Form from './../../../components/Form'
|
||||
|
||||
export default {
|
||||
data(){
|
||||
return {
|
||||
response: '',
|
||||
errorMessage: '',
|
||||
form: new Form({
|
||||
currentPassword : '',
|
||||
password : '',
|
||||
password_confirmation : '',
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
methods : {
|
||||
handleSubmit(e) {
|
||||
e.preventDefault()
|
||||
|
||||
this.errorMessage = ''
|
||||
this.response = ''
|
||||
|
||||
this.form.patch('/api/password')
|
||||
.then(response => {
|
||||
|
||||
this.response = response.data.message
|
||||
})
|
||||
.catch(error => {
|
||||
if( error.response.status === 400 ) {
|
||||
this.errorMessage = error.response.data.message
|
||||
}
|
||||
else if( error.response.status !== 422 ) {
|
||||
this.$router.push({ name: 'genericError', params: { err: error.response } });
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
111
resources/js/views/profile/Edit.vue
Normal file
111
resources/js/views/profile/Edit.vue
Normal file
@@ -0,0 +1,111 @@
|
||||
<template>
|
||||
<div class="section">
|
||||
<div class="columns is-mobile is-centered">
|
||||
<div class="column is-two-thirds-tablet is-half-desktop is-one-third-widescreen is-one-quarter-fullhd">
|
||||
<h1 class="title">{{ $t('commons.profile') }}</h1>
|
||||
<form @submit.prevent="handleSubmit" @keydown="form.onKeydown($event)">
|
||||
<div class="field">
|
||||
<label class="label">{{ $t('auth.forms.name') }}</label>
|
||||
<div class="control">
|
||||
<input id="name" type="text" class="input" v-model="form.name" autofocus />
|
||||
</div>
|
||||
<field-error :form="form" field="name" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label">{{ $t('auth.forms.email') }}</label>
|
||||
<div class="control">
|
||||
<input id="email" type="email" class="input" v-model="form.email" />
|
||||
</div>
|
||||
<field-error :form="form" field="email" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label">{{ $t('auth.forms.password') }}</label>
|
||||
<div class="control">
|
||||
<input id="password" type="password" class="input" v-model="form.password" />
|
||||
</div>
|
||||
<field-error :form="form" field="password" />
|
||||
</div>
|
||||
<div class="field is-grouped">
|
||||
<div class="control">
|
||||
<v-button :isLoading="form.isBusy" >{{ $t('commons.update') }}</v-button>
|
||||
</div>
|
||||
<div class="control">
|
||||
<router-link :to="{ name: 'accounts' }" class="button is-text">{{ $t('commons.cancel') }}</router-link>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field" v-if="errorMessage">
|
||||
<span class="tag is-danger">
|
||||
{{ errorMessage }}
|
||||
</span>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="columns is-mobile is-centered">
|
||||
<div class="column is-two-thirds-tablet is-half-desktop is-one-third-widescreen is-one-quarter-fullhd">
|
||||
<router-link :to="{ name: 'password.update' }" class="is-link">
|
||||
{{ $t('auth.forms.change_your_password') }}
|
||||
</router-link>
|
||||
</div>
|
||||
</div>
|
||||
<div class="columns is-mobile is-centered" v-if="response">
|
||||
<div class="has-text-link column is-two-thirds-tablet is-half-desktop is-one-third-widescreen is-one-quarter-fullhd">
|
||||
<span class="tag is-success">
|
||||
{{ response }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import Form from './../../components/Form'
|
||||
|
||||
export default {
|
||||
data(){
|
||||
return {
|
||||
response: '',
|
||||
errorMessage: '',
|
||||
form: new Form({
|
||||
name : '',
|
||||
email : '',
|
||||
password : '',
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
mounted: function() {
|
||||
this.form.get('/api/user')
|
||||
.then(response => {
|
||||
this.form.fill(response.data)
|
||||
})
|
||||
.catch(error => {
|
||||
this.$router.push({ name: 'genericError', params: { err: error.response } });
|
||||
});
|
||||
},
|
||||
|
||||
methods : {
|
||||
handleSubmit(e) {
|
||||
e.preventDefault()
|
||||
|
||||
this.errorMessage = ''
|
||||
this.response = ''
|
||||
|
||||
this.form.patch('/api/user')
|
||||
.then(response => {
|
||||
|
||||
this.response = response.data.message
|
||||
})
|
||||
.catch(error => {
|
||||
if( error.response.status === 400 ) {
|
||||
this.errorMessage = error.response.data.message
|
||||
}
|
||||
else if( error.response.status !== 422 ) {
|
||||
this.$router.push({ name: 'genericError', params: { err: error.response } });
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
Reference in New Issue
Block a user