1 year ago
#332537
karyme lopez
Reset password in Laravel by typing email manually
How can I make this reset password work without using a token and adding an email manually to reset password. Like for example in the image I want to change the password to the email I added which is edgar.lozoya@ujed.mx
How can I make this reset password work without using a token and adding an email manually to reset password.
Like for example in the image I want to change the password to the email I added which is edgar.lozoya@ujed.mx
This is the reset.blade.php: `@extends('layout.layout_reset')
@section('content') <section class=" container section">
<h1 class="h2 text-center">
Restablecer contraseña
</h1>
@alert(['class' => 'alert--has-icon size-caption'])
@endalert
<div class="login-form ">
<base-form action="{{ url('contrasena/restablecer') }}"
inline-template
v-cloak
>
<form method="POST" class="form-boxed" action="{{ route('password.update') }}" >
@csrf
<text-field name="token" type="hidden" v-model="fields.token" maxlength="60" placeholder="" ></text-field>
<div class="form-control">
<label for="email">Correo electrónico</label>
<text-field name="email" type="email" v-model="fields.email" maxlength="60" value="{{ $email ?? old('email') }}" placeholder="" initial=""></text-field>
<field-errors name="email"></field-errors>
@error('email')
<span class="invalid-feedback" role="alert">
<strong>{{$message}}</strong>
</span>
@enderror
</div>
<div class="form-control">
<label for="password">Nueva contraseña</label>
<text-field name="password" type="password" v-model="fields.password" maxlength="60" placeholder="" initial=""></text-field>
<field-errors name="password"></field-errors>
@error('password')
<span class="invalid-feedback" role="alert">
<strong>{{$message}}</strong>
</span>
@enderror
</div>
<div class="form-control">
<label for="password_confirmation">Confirmar nueva contraseña</label>
<text-field name="password_confirmation" type="password" v-model="fields.password_confirmation" maxlength="60" placeholder="" initial=""></text-field>
<field-errors name="password_confirmation"></field-errors>
@error('password_confirmation')
<span class="invalid-feedback" role="alert">
<strong>{{$message}}</strong>
</span>
@enderror
</div>
<div class="text-center">
<form-button type="submit" class="btn--success w-full">
Enviar
</form-button>
</div>
</form>
</base-form>
<br>
<br>
<br>
<br>
</div>
</section>
@endsection `
This is the reset password controller code: `<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller; use Illuminate\Foundation\Auth\ResetsPasswords; use App\User: class ResetPasswordController extends Controller { /* |-------------------------------------------------------------------------- | Password Reset Controller |-------------------------------------------------------------------------- | | This controller is responsible for handling password reset requests | and uses a simple trait to include this behavior. You're free to | explore this trait and override any methods you wish to tweak. | */
use ResetsPasswords;
/**
* Where to redirect users after resetting their password.
*
* @var string
*/
protected $redirectTo = 'admin';
protected function redirectTo(){
if( Auth()->user()->role == 1){
return route('admin.dashboard');
}
elseif( Auth()->user()->role == 2){
return route('admin.dashboard');
}
}
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
public function showResetForm(Request $request, $token = null)
{
return view('auth.passwords.reset')->with(
['token' => $token, 'email' => $request->email]
);
}
}
these are the routes in the web.php file
Route::post('passwords/reset', 'Auth\ResetPasswordController@reset')->name('password.update');
Route::post('auth/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email'); `
I tried eliminating the token variables and requesting the email in the reset password controller
php
laravel
reset
reset-password
0 Answers
Your Answer