samedi 3 août 2019

how can i fix this error:These credentials do not match our records

today i wanted to work with my laravel project but suddenly i received this error in all of my projects when i wanted to log in

These credentials do not match our records .

i don't change any thing but suddenly all of my project show me this error

i test some ways like:bycript and Hasht but they didn't work for me

my login controller

{

use AuthenticatesUsers;


protected $redirectTo = '/';


public function __construct()
{
    $this->middleware('guest')->except('logout');
}


protected function credentials(Request $request)
{
    return ['email'=>$request->{$this->username()},'password'=>$request->password,'verified'=>'1'];
}

public function redirectToProvider()
{
    return Socialite::driver('google')->redirect();
}

/**
 * Obtain the user information from GitHub.
 *
 * @return \Illuminate\Http\Response
 */
public function handleProviderCallback()
{
    $google_user = Socialite::driver('google')->user();


    $user=user::whereemail($google_user->getemail())->first();
    if (!$user){
        $user=user::create([
           'name'=>$google_user->getname(),
            'email'=>$google_user->getemail(),
            'password'=>bcrypt($google_user->getId()),
        ]);

        auth()->loginUsingId($user->id);


            return redirect('/home');


    }




}

}

trait AuthenticatesUsers {

public function showLoginForm()
{
    return view('auth.login');
}


public function login(Request $request)
{
    $this->validateLogin($request);


    if (method_exists($this, 'hasTooManyLoginAttempts') &&
        $this->hasTooManyLoginAttempts($request)) {
        $this->fireLockoutEvent($request);

        return $this->sendLockoutResponse($request);
    }

    if ($this->attemptLogin($request)) {
        return $this->sendLoginResponse($request);
    }


    $this->incrementLoginAttempts($request);

    return $this->sendFailedLoginResponse($request);
}


protected function validateLogin(Request $request)
{
    $request->validate([
        $this->username() => 'required|string',
        'password' => 'required|string',
    ]);
}


protected function attemptLogin(Request $request)
{
    return $this->guard()->attempt(
        $this->credentials($request), $request->filled('remember')
    );
}


protected function credentials(Request $request)
{
    return $request->only($this->username(), 'password');
}


protected function sendLoginResponse(Request $request)
{
    $request->session()->regenerate();

    $this->clearLoginAttempts($request);

    return $this->authenticated($request, $this->guard()->user())
            ?: redirect()->intended($this->redirectPath());
}


protected function authenticated(Request $request, $user)
{
    //
}


protected function sendFailedLoginResponse(Request $request)
{
    throw ValidationException::withMessages([
        $this->username() => [trans('auth.failed')],
    ]);
}


public function username()
{
    return 'email';
}


public function logout(Request $request)
{
    $this->guard()->logout();

    $request->session()->invalidate();

    return $this->loggedOut($request) ?: redirect('/');
}


protected function loggedOut(Request $request)
{
    //
}


protected function guard()
{
    return Auth::guard();
}

}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire