dimanche 22 mars 2020

Why Laravel adds another password hash?

I have function:

public function register(Request $request)
{

    $password = str_random(8);
    $password_hashed = Hash::make($password);
    $next_user_id = User::max('id') + 1;
    $login = 'operator_'.$next_user_id;

    $user = User::create([
        'email' => strtolower($login),
        'password' => $password_hashed,
        'name' => 'Operator'
    ]);

    $user->roles()->attach(Role::where('name', 'operator')->first());

    return \Response::json(['id' => $user->id, 'name' => $login, 'hash' => $password_hashed, 'password' => $password, 'roles' => ["name" => 'operator']]);

}

Laravel create an user with hashed password, why password $password_hashed is differ from added in database?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire