app/Http/Controllers/Auth/LoginController.php
private function doLogin(string $username, string $password): void
    {
        if (!$_COOKIE) {
            Log::addAuthenticationLog('Login failed (no session cookies): ' . $username);
            throw new Exception(I18N::translate('You cannot sign in because your browser does not accept cookies.'));
        }

        $user = $this->user_service->findByIdentifier($username);

        if ($user === null) {
            Log::addAuthenticationLog('Login failed (no such user/email): ' . $username);
            throw new Exception(I18N::translate('The username or password is incorrect.'));
        }

        if (!$user->checkPassword($password)) {
            Log::addAuthenticationLog('Login failed (incorrect password): ' . $username);
            throw new Exception(I18N::translate('The username or password is incorrect.'));
        }

        if (!$user->getPreference('verified')) {
            Log::addAuthenticationLog('Login failed (not verified by user): ' . $username);
            throw new Exception(I18N::translate('This account has not been verified. Please check your email for a verification message.'));
        }

        if (!$user->getPreference('verified_by_admin')) {
            Log::addAuthenticationLog('Login failed (not approved by admin): ' . $username);
            throw new Exception(I18N::translate('This account has not been approved. Please wait for an administrator to approve it.'));
        }

        Auth::login($user);
        Log::addAuthenticationLog('Login: ' . Auth::user()->userName() . '/' . Auth::user()->realName());
        Auth::user()->setPreference('sessiontime', (string) Carbon::now()->unix());

        Session::put('language', Auth::user()->getPreference('language'));
        Session::put('theme', Auth::user()->getPreference('theme'));
        I18N::init(Auth::user()->getPreference('language'));
    }
private function doLogin(string $username, string $password): void
    {
        if (!$_COOKIE) {
            Log::addAuthenticationLog('Login failed (no session cookies): ' . $username);
            throw new Exception(I18N::translate('You cannot sign in because your browser does not accept cookies.'));
        }

        $user = $this->user_service->findByIdentifier($username);

        if ($user === null) {
            Log::addAuthenticationLog('Login failed (no such user/email): ' . $username);
            throw new Exception(I18N::translate('The username or password is incorrect.'));
        }

        if (!$user->checkPassword($password)) {
            Log::addAuthenticationLog('Login failed (incorrect password): ' . $username);
            throw new Exception(I18N::translate('The username or password is incorrect.'));
        }

        if (!$user->getPreference('verified')) {
            Log::addAuthenticationLog('Login failed (not verified by user): ' . $username);
            throw new Exception(I18N::translate('This account has not been verified. Please check your email for a verification message.'));
        }

        if (!$user->getPreference('verified_by_admin')) {
            Log::addAuthenticationLog('Login failed (not approved by admin): ' . $username);
            throw new Exception(I18N::translate('This account has not been approved. Please wait for an administrator to approve it.'));
        }

        Auth::login($user);
        Log::addAuthenticationLog('Login: ' . Auth::user()->userName() . '/' . Auth::user()->realName());
        Auth::user()->setPreference('sessiontime', (string) Carbon::now()->unix());

        Session::put('language', Auth::user()->getPreference('language'));
        Session::put('theme', Auth::user()->getPreference('theme'));
        I18N::init(Auth::user()->getPreference('language'));
    }
private function doLogin ( string $ username , string $ password ) : void { if ( ! $ _COOKIE ) { Log :: addAuthenticationLog ( 'Login failed (no session cookies): ' . $ username ) ; throw new Exception ( I18N :: translate ( 'You cannot sign in because your browser does not accept cookies.' ) ) ; } $ user = $ this -> user_service -> findByIdentifier ( $ username ) ; if ( $ user === null ) { Log :: addAuthenticationLog ( 'Login failed (no such user/email): ' . $ username ) ; throw new Exception ( I18N :: translate ( 'The username or password is incorrect.' ) ) ; } if ( ! $ user -> checkPassword ( $ password ) ) { Log :: addAuthenticationLog ( 'Login failed (incorrect password): ' . $ username ) ; throw new Exception ( I18N :: translate ( 'The username or password is incorrect.' ) ) ; } if ( ! $ user -> getPreference ( 'verified' ) ) { Log :: addAuthenticationLog ( 'Login failed (not verified by user): ' . $ username ) ; throw new Exception ( I18N :: translate ( 'This account has not been verified. Please check your email for a verification message.' ) ) ; } if ( ! $ user -> getPreference ( 'verified_by_admin' ) ) { Log :: addAuthenticationLog ( 'Login failed (not approved by admin): ' . $ username ) ; throw new Exception ( I18N :: translate ( 'This account has not been approved. Please wait for an administrator to approve it.' ) ) ; } Auth :: login ( $ user ) ; Log :: addAuthenticationLog ( 'Login: ' . Auth :: user ( ) -> userName ( ) . '/' . Auth :: user ( ) -> realName ( ) ) ; Auth :: user ( ) -> setPreference ( 'sessiontime' , ( string ) Carbon :: now ( ) -> unix ( ) ) ; Session :: put ( 'language' , Auth :: user ( ) -> getPreference ( 'language' ) ) ; Session :: put ( 'theme' , Auth :: user ( ) -> getPreference ( 'theme' ) ) ; I18N :: init ( Auth :: user ( ) -> getPreference ( 'language' ) ) ; }
Log in, if we can.  Throw an exception, if we can't.

@param string $username
@param string $password

@return void
@throws Exception
Log in if we can . Throw an exception if we can t .