Tuesday, March 14, 2017

Redirect to view just before logging in Laravel 5.4

How do i redirect someone who tries to login to another view to add a extra step to the authentication?

I tried this in the AuthenticateUsers.php

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

        // If the class is using the ThrottlesLogins trait, we can automatically throttle
        // the login attempts for this application. We'll key this by the username and
        // the IP address of the client making these requests into this application.
        if ($this->hasTooManyLoginAttempts($request)) {
            $this->fireLockoutEvent($request);

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

        if ($this->attemptLogin($request)) {
            //return $this->sendLoginResponse($request);
            return redirect('/auth/'.Auth::id());
        }

        // If the login attempt was unsuccessful we will increment the number of attempts
        // to login and redirect the user back to the login form. Of course, when this
        // user surpasses their maximum number of attempts they will get locked out.
        $this->incrementLoginAttempts($request);

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

I'm trying to make it show the "/auth/" view just before logging in, and it does show the view but it still logs me in.



via Mario Eekma

Advertisement