public function setLoginData($mIdEmail, $bSetSessionData = true)
    {
        //  Valid user?
        if (is_numeric($mIdEmail)) {

            $oUser  = $this->getById($mIdEmail);
            $sError = 'Invalid User ID.';

        } elseif (is_string($mIdEmail)) {

            Factory::helper('email');
            if (valid_email($mIdEmail)) {
                $oUser  = $this->getByEmail($mIdEmail);
                $sError = 'Invalid User email.';
            } else {
                $this->setError('Invalid User email.');
                return false;
            }

        } else {

            $this->setError('Invalid user ID or email.');
            return false;
        }

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

        //  Test user
        if (!$oUser) {

            $this->setError($sError);
            return false;

        } elseif ($oUser->is_suspended) {

            $this->setError('User is suspended.');
            return false;

        } else {

            //  Set the flag
            $this->bIsLoggedIn = true;

            //  Set session variables
            if ($bSetSessionData) {
                $oSession = Factory::service('Session', 'nails/module-auth');
                $oSession->setUserData([
                    'id'       => $oUser->id,
                    'email'    => $oUser->email,
                    'group_id' => $oUser->group_id,
                ]);
            }

            //  Set the active user
            $this->setActiveUser($oUser);

            return true;
        }
    }
public function setLoginData($mIdEmail, $bSetSessionData = true)
    {
        //  Valid user?
        if (is_numeric($mIdEmail)) {

            $oUser  = $this->getById($mIdEmail);
            $sError = 'Invalid User ID.';

        } elseif (is_string($mIdEmail)) {

            Factory::helper('email');
            if (valid_email($mIdEmail)) {
                $oUser  = $this->getByEmail($mIdEmail);
                $sError = 'Invalid User email.';
            } else {
                $this->setError('Invalid User email.');
                return false;
            }

        } else {

            $this->setError('Invalid user ID or email.');
            return false;
        }

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

        //  Test user
        if (!$oUser) {

            $this->setError($sError);
            return false;

        } elseif ($oUser->is_suspended) {

            $this->setError('User is suspended.');
            return false;

        } else {

            //  Set the flag
            $this->bIsLoggedIn = true;

            //  Set session variables
            if ($bSetSessionData) {
                $oSession = Factory::service('Session', 'nails/module-auth');
                $oSession->setUserData([
                    'id'       => $oUser->id,
                    'email'    => $oUser->email,
                    'group_id' => $oUser->group_id,
                ]);
            }

            //  Set the active user
            $this->setActiveUser($oUser);

            return true;
        }
    }
public function setLoginData ( $ mIdEmail , $ bSetSessionData = true ) { //  Valid user? if ( is_numeric ( $ mIdEmail ) ) { $ oUser = $ this -> getById ( $ mIdEmail ) ; $ sError = 'Invalid User ID.' ; } elseif ( is_string ( $ mIdEmail ) ) { Factory :: helper ( 'email' ) ; if ( valid_email ( $ mIdEmail ) ) { $ oUser = $ this -> getByEmail ( $ mIdEmail ) ; $ sError = 'Invalid User email.' ; } else { $ this -> setError ( 'Invalid User email.' ) ; return false ; } } else { $ this -> setError ( 'Invalid user ID or email.' ) ; return false ; } // -------------------------------------------------------------------------- //  Test user if ( ! $ oUser ) { $ this -> setError ( $ sError ) ; return false ; } elseif ( $ oUser -> is_suspended ) { $ this -> setError ( 'User is suspended.' ) ; return false ; } else { //  Set the flag $ this -> bIsLoggedIn = true ; //  Set session variables if ( $ bSetSessionData ) { $ oSession = Factory :: service ( 'Session' , 'nails/module-auth' ) ; $ oSession -> setUserData ( [ 'id' => $ oUser -> id , 'email' => $ oUser -> email , 'group_id' => $ oUser -> group_id , ] ) ; } //  Set the active user $ this -> setActiveUser ( $ oUser ) ; return true ; } }
Set the user's login data

@param mixed   $mIdEmail        The user's ID or email address
@param boolean $bSetSessionData Whether to set the session data or not

@return boolean
Set the user s login data