Check whether password is correct or not in Laravel

后端 未结 6 1628
傲寒
傲寒 2020-12-31 00:23

In laravel I want to check if user enter current password than check with that password which is store in database in that user data. If correct than continue otherwise give

6条回答
  •  灰色年华
    2020-12-31 00:45

    Just do it

    public function authenticateEmployee(array $data){
    
     $email = $data['email'];
     $password = $data['password'];
    
     $user = User::where('email', '=', $email)->first();   //get db User data   
     if(Hash::check($password, $user->password)) {   
    
          return response()->json(['status'=>'false','message'=>'password is correct']);
    
        } else {
            return 'false';
        }
    
    }
    

提交回复
热议问题