I want to create form with 3 field (old_password, new_password, confirm_password) with laravel 5.
View
old password :
{!! Form::password(
I am explain here another method to change user password changepassword.blade.php
@extends('layouts.app')
@section('content')
Change password
@if (session('error'))
{{ session('error') }}
@endif
@if (session('success'))
{{ session('success') }}
@endif
@endsection
This is route in web.php
Route::post('/changePassword','HomeController@changePassword')->name('changePassword');
Controller Method
public function changePassword(Request $request){
if (!(Hash::check($request->get('current-password'), Auth::user()->password))) {
// The passwords matches
return redirect()->back()->with("error","Your current password does not matches with the password you provided. Please try again.");
}
if(strcmp($request->get('current-password'), $request->get('new-password')) == 0){
//Current password and new password are same
return redirect()->back()->with("error","New Password cannot be same as your current password. Please choose a different password.");
}
$validatedData = $request->validate([
'current-password' => 'required',
'new-password' => 'required|string|min:6|confirmed',
]);
//Change Password
$user = Auth::user();
$user->password = bcrypt($request->get('new-password'));
$user->save();
return redirect()->back()->with("success","Password changed successfully !");
}
i have follow that link :- https://www.5balloons.info/setting-up-change-password-with-laravel-authentication/