0

I have stored procedure that accepts login and password, and gives or status or user id. I extended LoginController for working with this. This is working until I'll input correct data. After execution of procedure I'm trying to authorize user via id but it's wrong (and User model doesn't exists).

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

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

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

    $result = DB::select(DB::raw("SET NOCOUNT ON {CALL users.Login (@Login =:username, @Password =:password)}"),[
        ':username' => $request->login,
        ':password' => $request->password,
    ]);

    switch($result[0]->status){
        case '-3':
            $message = "Login is banned";
            break;
        case '-2':
            $message = 'Wrong password';
            break;
        case '-1':
            $message = 'You are haven\'t rights';
            break;
    }

    if ($result[0]->status > 0) {
        //Auth::loginUsingId($result[0]->status);
        return $this->sendLoginResponse($request);
    }

    $this->incrementLoginAttempts($request);

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

I'm accepting this error:

Symfony\Component\Debug\Exception\FatalThrowableError Class

'\App\Models\User' not found

How to write user data to session and use it via Auth facade?


P.S I now that exists this question but no answer here...

Community
  • 1
  • 1
Vladimir Gonchar
  • 203
  • 5
  • 16

1 Answers1

0

Class '\App\Models\User' not found mean the user model does not exist. If you think that model exists in App/Models make sure the namespace(code in the top) is namespace App\Models;

The second case is you might try to login with status? You should use Auth::loginUsingId($result[0]->id) rather than status.

I recommend you using Auth::attempt() like Auth::attempt(['login' => request('login'), 'password' => request('password')])

Muhammad Dyas Yaskur
  • 6,914
  • 10
  • 48
  • 73
  • I fixed this (I forgot rename namespace). But there is no users table in database and I can't get any information from such table. I can only check request via procedure and get information from another procedure by user id. – Vladimir Gonchar Dec 25 '19 at 12:46
  • Sorry, I don't get it, so this question is solved or not? – Muhammad Dyas Yaskur Dec 25 '19 at 12:54