Encrypt passwords

-1

I need to generate a default password for users of my login table. The password must be the same for all users for first access to the system. The registration already exists, but I have to modify the passwords. The problem happens when I update passwords, only the first user of the table can log in.

public function recadastroSenha(){

    $users = User::whereRaw("flag_del = 0 ")->get();

    foreach($users as $user){

        $senha = "senha123";
        $user->password = bcrypt($senha);            
    } 
    $user->save();
}

Even if you update all table rows with different encryptions, only the first user performs login .

    
asked by anonymous 02.06.2016 / 18:15

1 answer

0

It would have to be the save method within for to change password :

public function recadastroSenha(){

    $users = User::whereRaw("flag_del = 0 ")->get();

    foreach($users as $user){

        $senha = "senha123";

        $user->password = bcrypt($senha);

        $user->save();

    } 

}
    
02.06.2016 / 19:19