protected function loginUser()
    {
        //  Set login data for this user
        $oUserModel = Factory::model('User', 'nails/module-auth');
        $oUserModel->setLoginData($this->mfaUser->id);

        //  If we're remembering this user set a cookie
        if ($this->remember) {
            $oUserModel->setRememberCookie(
                $this->mfaUser->id,
                $this->mfaUser->password,
                $this->mfaUser->email
            );
        }

        //  Update their last login and increment their login count
        $oUserModel->updateLastLogin($this->mfaUser->id);

        // --------------------------------------------------------------------------

        //  Generate an event for this log in
        create_event('did_log_in', ['method' => $this->loginMethod], $this->mfaUser->id);

        // --------------------------------------------------------------------------

        //  Say hello
        if ($this->mfaUser->last_login) {

            $oConfig = Factory::service('Config');

            if ($oConfig->item('authShowNicetimeOnLogin')) {
                $sLastLogin = niceTime(strtotime($this->mfaUser->last_login));
            } else {
                $sLastLogin = toUserDatetime($this->mfaUser->last_login);
            }

            if ($oConfig->item('authShowLastIpOnLogin')) {

                $sStatus  = 'positive';
                $sMessage = lang(
                    'auth_login_ok_welcome_with_ip',
                    [
                        $this->mfaUser->first_name,
                        $sLastLogin,
                        $this->mfaUser->last_ip,
                    ]
                );

            } else {

                $sStatus  = 'positive';
                $sMessage = lang(
                    'auth_login_ok_welcome',
                    [
                        $this->mfaUser->first_name,
                        $sLastLogin,
                    ]
                );
            }

        } else {

            $sStatus  = 'positive';
            $sMessage = lang(
                'auth_login_ok_welcome_notime',
                [
                    $this->mfaUser->first_name,
                ]
            );
        }

        $oSession = Factory::service('Session', 'nails/module-auth');
        $oSession->setFlashData($sStatus, $sMessage);

        // --------------------------------------------------------------------------

        //  Delete the token we generated, it's no needed, eh!
        $oAuthModel = Factory::model('Auth', 'nails/module-auth');
        $oAuthModel->mfaTokenDelete($this->data['token']['id']);

        // --------------------------------------------------------------------------

        $sRedirectUrl = $this->returnTo != site_url() ? $this->returnTo : $this->mfaUser->group_homepage;
        redirect($sRedirectUrl);
    }
protected function loginUser()
    {
        //  Set login data for this user
        $oUserModel = Factory::model('User', 'nails/module-auth');
        $oUserModel->setLoginData($this->mfaUser->id);

        //  If we're remembering this user set a cookie
        if ($this->remember) {
            $oUserModel->setRememberCookie(
                $this->mfaUser->id,
                $this->mfaUser->password,
                $this->mfaUser->email
            );
        }

        //  Update their last login and increment their login count
        $oUserModel->updateLastLogin($this->mfaUser->id);

        // --------------------------------------------------------------------------

        //  Generate an event for this log in
        create_event('did_log_in', ['method' => $this->loginMethod], $this->mfaUser->id);

        // --------------------------------------------------------------------------

        //  Say hello
        if ($this->mfaUser->last_login) {

            $oConfig = Factory::service('Config');

            if ($oConfig->item('authShowNicetimeOnLogin')) {
                $sLastLogin = niceTime(strtotime($this->mfaUser->last_login));
            } else {
                $sLastLogin = toUserDatetime($this->mfaUser->last_login);
            }

            if ($oConfig->item('authShowLastIpOnLogin')) {

                $sStatus  = 'positive';
                $sMessage = lang(
                    'auth_login_ok_welcome_with_ip',
                    [
                        $this->mfaUser->first_name,
                        $sLastLogin,
                        $this->mfaUser->last_ip,
                    ]
                );

            } else {

                $sStatus  = 'positive';
                $sMessage = lang(
                    'auth_login_ok_welcome',
                    [
                        $this->mfaUser->first_name,
                        $sLastLogin,
                    ]
                );
            }

        } else {

            $sStatus  = 'positive';
            $sMessage = lang(
                'auth_login_ok_welcome_notime',
                [
                    $this->mfaUser->first_name,
                ]
            );
        }

        $oSession = Factory::service('Session', 'nails/module-auth');
        $oSession->setFlashData($sStatus, $sMessage);

        // --------------------------------------------------------------------------

        //  Delete the token we generated, it's no needed, eh!
        $oAuthModel = Factory::model('Auth', 'nails/module-auth');
        $oAuthModel->mfaTokenDelete($this->data['token']['id']);

        // --------------------------------------------------------------------------

        $sRedirectUrl = $this->returnTo != site_url() ? $this->returnTo : $this->mfaUser->group_homepage;
        redirect($sRedirectUrl);
    }
protected function loginUser ( ) { //  Set login data for this user $ oUserModel = Factory :: model ( 'User' , 'nails/module-auth' ) ; $ oUserModel -> setLoginData ( $ this -> mfaUser -> id ) ; //  If we're remembering this user set a cookie if ( $ this -> remember ) { $ oUserModel -> setRememberCookie ( $ this -> mfaUser -> id , $ this -> mfaUser -> password , $ this -> mfaUser -> email ) ; } //  Update their last login and increment their login count $ oUserModel -> updateLastLogin ( $ this -> mfaUser -> id ) ; // -------------------------------------------------------------------------- //  Generate an event for this log in create_event ( 'did_log_in' , [ 'method' => $ this -> loginMethod ] , $ this -> mfaUser -> id ) ; // -------------------------------------------------------------------------- //  Say hello if ( $ this -> mfaUser -> last_login ) { $ oConfig = Factory :: service ( 'Config' ) ; if ( $ oConfig -> item ( 'authShowNicetimeOnLogin' ) ) { $ sLastLogin = niceTime ( strtotime ( $ this -> mfaUser -> last_login ) ) ; } else { $ sLastLogin = toUserDatetime ( $ this -> mfaUser -> last_login ) ; } if ( $ oConfig -> item ( 'authShowLastIpOnLogin' ) ) { $ sStatus = 'positive' ; $ sMessage = lang ( 'auth_login_ok_welcome_with_ip' , [ $ this -> mfaUser -> first_name , $ sLastLogin , $ this -> mfaUser -> last_ip , ] ) ; } else { $ sStatus = 'positive' ; $ sMessage = lang ( 'auth_login_ok_welcome' , [ $ this -> mfaUser -> first_name , $ sLastLogin , ] ) ; } } else { $ sStatus = 'positive' ; $ sMessage = lang ( 'auth_login_ok_welcome_notime' , [ $ this -> mfaUser -> first_name , ] ) ; } $ oSession = Factory :: service ( 'Session' , 'nails/module-auth' ) ; $ oSession -> setFlashData ( $ sStatus , $ sMessage ) ; // -------------------------------------------------------------------------- //  Delete the token we generated, it's no needed, eh! $ oAuthModel = Factory :: model ( 'Auth' , 'nails/module-auth' ) ; $ oAuthModel -> mfaTokenDelete ( $ this -> data [ 'token' ] [ 'id' ] ) ; // -------------------------------------------------------------------------- $ sRedirectUrl = $ this -> returnTo != site_url ( ) ? $ this -> returnTo : $ this -> mfaUser -> group_homepage ; redirect ( $ sRedirectUrl ) ; }
Logs a user In
Logs a user In