mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-01-11 16:58:58 +01:00
Add reset password form
This commit is contained in:
parent
46de6f1da1
commit
03d1e2aec6
@ -20,13 +20,6 @@ class ResetPasswordController extends Controller
|
|||||||
|
|
||||||
use ResetsPasswords;
|
use ResetsPasswords;
|
||||||
|
|
||||||
/**
|
|
||||||
* Where to redirect users after resetting their password.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $redirectTo = '/home';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new controller instance.
|
* Create a new controller instance.
|
||||||
*
|
*
|
||||||
@ -36,4 +29,28 @@ public function __construct()
|
|||||||
{
|
{
|
||||||
$this->middleware('guest');
|
$this->middleware('guest');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the response for a successful password reset.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param string $response
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
protected function sendResetResponse(Request $request, $response)
|
||||||
|
{
|
||||||
|
return ['status' => trans($response)];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the response for a failed password reset.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\Request $request
|
||||||
|
* @param string $response
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
protected function sendResetFailedResponse(Request $request, $response)
|
||||||
|
{
|
||||||
|
return response()->json(['email' => trans($response)], 400);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
3
resources/js/app.js
vendored
3
resources/js/app.js
vendored
@ -13,6 +13,7 @@ import Accounts from './views/Accounts'
|
|||||||
import Create from './views/Create'
|
import Create from './views/Create'
|
||||||
import Edit from './views/Edit'
|
import Edit from './views/Edit'
|
||||||
import PasswordRequest from './views/auth/password/Request'
|
import PasswordRequest from './views/auth/password/Request'
|
||||||
|
import PasswordReset from './views/auth/password/Reset'
|
||||||
import NotFound from './views/Error'
|
import NotFound from './views/Error'
|
||||||
|
|
||||||
|
|
||||||
@ -42,7 +43,7 @@ const router = new VueRouter({
|
|||||||
{ path: '/edit/:twofaccountId', name: 'edit',component: Edit },
|
{ path: '/edit/:twofaccountId', name: 'edit',component: Edit },
|
||||||
|
|
||||||
{ path: '/password/request', name: 'password.request', component: PasswordRequest },
|
{ path: '/password/request', name: 'password.request', component: PasswordRequest },
|
||||||
//{ path: '/password/reset/:token', name: 'password.reset', component: page('auth/password/reset.vue') },
|
{ path: '/password/reset/:token', name: 'password.reset', component: PasswordReset },
|
||||||
|
|
||||||
{ path: '/flooded', name: 'flooded',component: NotFound,props: true },
|
{ path: '/flooded', name: 'flooded',component: NotFound,props: true },
|
||||||
{ path: '/error', name: 'genericError',component: NotFound,props: true },
|
{ path: '/error', name: 'genericError',component: NotFound,props: true },
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
<div class="section">
|
<div class="section">
|
||||||
<div class="columns is-mobile is-centered">
|
<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">
|
<div class="column is-two-thirds-tablet is-half-desktop is-one-third-widescreen is-one-quarter-fullhd">
|
||||||
<h1 class="title">{{ $t('passwords.reset_password') }}</h1>
|
<h1 class="title">{{ $t('auth.reset_password') }}</h1>
|
||||||
<form method="POST" action="/login">
|
<form method="POST" action="/password/email">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label">{{ $t('auth.forms.email') }}</label>
|
<label class="label">{{ $t('auth.forms.email') }}</label>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
@ -13,7 +13,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="field is-grouped">
|
<div class="field is-grouped">
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<button type="submit" class="button is-link" @click="handleSubmit">{{ $t('passwords.send_password_reset_link') }}</button>
|
<button type="submit" class="button is-link" @click="handleSubmit">{{ $t('auth.send_password_reset_link') }}</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<router-link :to="{ name: 'login' }" class="button is-text">{{ $t('commons.cancel') }}</router-link>
|
<router-link :to="{ name: 'login' }" class="button is-text">{{ $t('commons.cancel') }}</router-link>
|
||||||
@ -22,6 +22,12 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="columns is-mobile is-centered" v-if="response">
|
||||||
|
<div class="column is-two-thirds-tablet is-half-desktop is-one-third-widescreen is-one-quarter-fullhd">
|
||||||
|
{{ response }}
|
||||||
|
</router-link>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -30,7 +36,8 @@
|
|||||||
data(){
|
data(){
|
||||||
return {
|
return {
|
||||||
email : '',
|
email : '',
|
||||||
validationErrors: {}
|
validationErrors: {},
|
||||||
|
response: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods : {
|
methods : {
|
||||||
@ -41,12 +48,14 @@
|
|||||||
email: this.email
|
email: this.email
|
||||||
})
|
})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
alert('email sent')
|
this.response = response.data.status
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.log(error.response)
|
console.log(error.response)
|
||||||
if( error.response.data.errors ) {
|
if( error.response.data.errors ) {
|
||||||
this.validationErrors = error.response.data.errors
|
this.validationErrors = error.response.data.errors
|
||||||
|
} else if( error.response.data ) {
|
||||||
|
this.response = error.response.data.email
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.$router.push({ name: 'genericError', params: { err: error.response.data.message } });
|
this.$router.push({ name: 'genericError', params: { err: error.response.data.message } });
|
||||||
|
90
resources/js/views/auth/password/Reset.vue
Normal file
90
resources/js/views/auth/password/Reset.vue
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
<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.new_password') }}</h1>
|
||||||
|
<form method="POST" action="/password/reset">
|
||||||
|
<div class="field">
|
||||||
|
<label class="label">{{ $t('auth.forms.email') }}</label>
|
||||||
|
<div class="control">
|
||||||
|
<input id="email" type="email" class="input" v-model="email" required />
|
||||||
|
</div>
|
||||||
|
<p class="help is-danger" v-if="validationErrors.email">{{ validationErrors.email.toString() }}</p>
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<label class="label">{{ $t('auth.forms.password') }}</label>
|
||||||
|
<div class="control">
|
||||||
|
<input id="password" type="password" class="input" v-model="password" required />
|
||||||
|
</div>
|
||||||
|
<p class="help is-danger" v-if="validationErrors.password">{{ validationErrors.password.toString() }}</p>
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<label class="label">{{ $t('auth.forms.password_confirmation') }}</label>
|
||||||
|
<div class="control">
|
||||||
|
<input id="password_confirmation" type="password" class="input" v-model="password_confirmation" required />
|
||||||
|
</div>
|
||||||
|
<p class="help is-danger" v-if="validationErrors.password_confirmation">{{ validationErrors.password_confirmation.toString() }}</p>
|
||||||
|
</div>
|
||||||
|
<div class="field is-grouped">
|
||||||
|
<div class="control">
|
||||||
|
<button type="submit" class="button is-link" @click="handleSubmit">{{ $t('auth.register') }}</button>
|
||||||
|
</div>
|
||||||
|
<div class="control">
|
||||||
|
<router-link :to="{ name: 'login' }" class="button is-text">{{ $t('commons.cancel') }}</router-link>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
data(){
|
||||||
|
return {
|
||||||
|
token : '',
|
||||||
|
email : '',
|
||||||
|
password : '',
|
||||||
|
password_confirmation : '',
|
||||||
|
validationErrors: {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
created () {
|
||||||
|
this.email = this.$route.query.email
|
||||||
|
this.token = this.$route.params.token
|
||||||
|
},
|
||||||
|
|
||||||
|
methods : {
|
||||||
|
handleSubmit(e) {
|
||||||
|
e.preventDefault()
|
||||||
|
|
||||||
|
axios.post('api/password/reset', {
|
||||||
|
email: this.email,
|
||||||
|
password: this.password,
|
||||||
|
password_confirmation : this.password_confirmation,
|
||||||
|
token: this.token
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
console.log(response)
|
||||||
|
// localStorage.setItem('user',response.data.message.name)
|
||||||
|
// localStorage.setItem('jwt',response.data.message.token)
|
||||||
|
|
||||||
|
// if (localStorage.getItem('jwt') != null){
|
||||||
|
// this.$router.go('/');
|
||||||
|
// }
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.log(error.response)
|
||||||
|
if( error.response.data.errors ) {
|
||||||
|
this.validationErrors = error.response.data.errors
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.$router.push({ name: 'genericError', params: { err: error.response.data.message } });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
Loading…
Reference in New Issue
Block a user