jeudi 5 mars 2020

Laravel Empty Password hashing

When I trying to update user data and let The Password Field empty it hashed again that means the password will change and you can't log in again so is there any way to fix this problem ??

Code

$this->validate($request, [
        'first_name'=> 'required|string',
        'last_name' =>  'required|string',
        'email'     =>  'required|email|unique:users,email,'.Auth::id(),
        'password'  =>  'sometimes|nullable|string|min:8,'.Auth::id(),
        'avatar'    =>  'image|mimes:jpg,jpeg,gif,png,svg|max:2048,'.Auth::id(),
        'gender'    =>  'required',
        'country_id'=>  'required',
    ]);

    $user = User::find(Auth::id());

    $user->first_name = $request->first_name;
    $user->last_name = $request->last_name;
    $user->email = $request->email;
    $user->gender = $request->gender;
    $user->country_id = $request->country_id;
    $user->password = bcrypt(request('password'));
    if($request->hasFile('avatar')){
        $avatar = $request->file('avatar');
        $filename = time() . '.' . $avatar->getClientOriginalExtension();
        Image::make($avatar)->resize(300, 300)->save( public_path('/images/avatars/' . $filename ) );
        $user->avatar = $filename;
    }

    $user->save();

    return redirect()->back();


via Chebli Mohamed

1 commentaire:

  1. Strange "water hack" burns 2lbs overnight

    Well over 160 thousand men and women are hacking their diet with a easy and secret "liquids hack" to drop 1-2lbs each and every night while they sleep.

    It's very simple and it works on everybody.

    Just follow these easy step:

    1) Go get a clear glass and fill it with water half full

    2) And then do this proven hack

    so you'll become 1-2lbs skinnier the next day!

    RépondreSupprimer