Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel 8 change password

<?php

#appHttpControllersHomeController.php

namespace AppHttpControllers;

use IlluminateHttpRequest;
use AppModelsUser;
use Hash;
use Auth;

class HomeController extends Controller
{
    public function showChangePasswordGet() {
        return view('auth.passwords.change-password');
    }

    public function changePasswordPost(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.");
        }

        if(strcmp($request->get('current-password'), $request->get('new-password')) == 0){
            // Current password and new password same
            return redirect()->back()->with("error","New Password cannot be same as your current password.");
        }

        $validatedData = $request->validate([
            'current-password' => 'required',
            'new-password' => 'required|string|min:8|confirmed',
        ]);

        //Change Password
        $user = Auth::user();
        $user->password = bcrypt($request->get('new-password'));
        $user->save();

        return redirect()->back()->with("success","Password successfully changed!");
    }
}
Comment

PREVIOUS NEXT
Code Example
Php :: laravel blade image 
Php :: br php 
Php :: php curl asyc 
Php :: laravel with has 
Php :: file to binary php 
Php :: php foreach count rows 
Php :: wordpress query multiple post ids 
Php :: wordpress require file from plugins folder 
Php :: how to add attributes to an exsisting object in php 
Php :: laravel migration change column default 
Php :: laravel database select 
Php :: htaccess php version 
Php :: laravel unique validation 
Php :: php generate slug 
Php :: codeigniter redirect 
Php :: php create an image 
Php :: laravel 8 insert multiple rows 
Php :: php sort array by specific key 
Php :: fetch value from json link in php 
Php :: how to bulk insert array into sql php 
Php :: php initialize array 
Php :: load database in codeigniter 
Php :: php remove anchor tag from string 
Php :: laravel migration index 
Php :: wordpress get current taxonomy 
Php :: laravel model update 
Php :: reset password multipple database laravel 
Php :: snap store phpstrom 
Php :: search post by post title in wordpres 
Php :: how to prompt user for input in php 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =