2 years ago

Encrypt a password in database update

Posted 2 years ago by iGenezys

Hi guys, sorry for my english. I have a problem in a Laravel project, I want to update an user's password, but when I do it, the password is not encrypted. I put here my update code :

public function update($id, Request $request){

        $user = User::whereId($id)->first();

        $mdpuser = $request->input('passwordactu');

        $verifypass = password_verify($mdpuser, $user->password);

        if ($verifypass == true)
            $this->validate($request, [

                'name' => "required|max:255|alpha_num|unique:users,name,{$user->id}",


            $user->update($request->only('name', 'nom', 'prenom', 'role', 'password'));

            return Redirect::route('gestionUser.index')->with('success', 'La modification a correctement été effectuée');


            return Redirect::route('gestionUser.index')->with('error', 'Il y a eu une erreur, merci de recommencer');


I try somethind like put a "bcrypt('password')" in my Update line, but in that case, the password is not updated in the database. Here, it's updated, but not encrypted.

Do you have an idea that can help me here ? Thank you !

Please sign in or create an account to participate in this conversation.