mercredi 31 janvier 2018

Laravel Auth Controller Change code for redirect

I want change in my AuthController, after the user sign in, he redirect to an 2fa site before he can visit home.

My code now:

        if (Auth::attempt(['username' => $request->username, 'password' => $request->password])) {

          $user = Auth::user();

          $user->last_seen = date('Y-m-d H:i:s', time());

          $user->save();

          return redirect()->route('home');



        } else {

          session()->flash('errormessage','Invalid password ');

          return redirect()->back();

        }

}

After the $user->last_seen = date('Y-m-d H:i:s', time()); saved he must redirect to return redirect('messagedecrypt');

Like this code:

   if (!Hash::check($request->password,$user->password) && !Hash::check($request->username,$user->username)) 
    {
      session()->flash('errormessage','Your Login Credential Are Wrong');
      return redirect()->back();
    } 
    else 
    {
      session()->flash('user_name',$request->username);
      session()->flash('user_password',$request->password);
      return redirect('messagedecrypt');
    }

}

How can i change my code now with also saving last seen?

Thanks



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2DQv16l
via IFTTT

Aucun commentaire:

Enregistrer un commentaire