Monday, May 7, 2018

Laravel: How to register user through login? - development

Laravel: How to register user through login?

I am using the standard method of login/registration of Auth Controllers. The goal is to register a new user when the user logs in if there is no such user, or just auth if there is. To my mind, it should be simply reassigning a couple of methods. For start, I changed

AuthenticatesUsers.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);
    }

    // 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);
}

With commenting the last line it will not say that there is no such user, and I believe right there I should put register method, but I can’t find the right way to include it. I suggest that I should use RegisterUsers.php



from Laravel Questions and Answers https://laravelquestions.com/php/laravel-how-to-register-user-through-login/
via Lzo Media

No comments:

Post a Comment