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
332662
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;
        }
    }
453632
public function setUserData($mKey, $mValue = null)
    {
        $this->setup(true);
        if (empty($this->oSession)) {
            return $this;
        }

        $this->oSession->set_userdata($mKey, $mValue);
        return $this;
    }
386701
boolean sendMail() {

        if(!this.isPropertiesSet()) {
            logger.debug(LOG_PREFIX + ": Required Mail Properties are not set. Attachments will not be sent");
            return false;
        }

        Properties prop = new Properties();
        prop.put("mail.smtp.auth", true);
        prop.put("mail.smtp.starttls.enable", "true");
        prop.put("mail.smtp.host", this.host);
        prop.put("mail.smtp.port", this.port);
        prop.put("mail.smtp.ssl.trust", host);

        logger.debug(LOG_PREFIX + ": Mail properties set");

        Session session = Session.getInstance(prop, new Authenticator() {
            @Override
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(username, password);
            }
        });

        logger.debug(LOG_PREFIX + ": Mail Session Created");

        try {
//			create a default mime message object
            Message message = new MimeMessage(session);
            message.setFrom(new InternetAddress(fromAdd));
            message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(toAdd));
            message.setSubject(subject);

//          body part for message
            MimeBodyPart mimeBodyPart = new MimeBodyPart();
            mimeBodyPart.setContent(msg, "text/html");

//          body part for attachments
            MimeBodyPart attachmentBodyPart = new MimeBodyPart();
            logger.debug(LOG_PREFIX + ": " + this.attachments.length + " attachments found");
            for (File file: this.attachments) {
                attachmentBodyPart.attachFile(file);
            }

//          create a multipart to combine them together
            Multipart multipart = new MimeMultipart();
            multipart.addBodyPart(mimeBodyPart);
            multipart.addBodyPart(attachmentBodyPart);

            //now set the multipart as the content of the message
            message.setContent(multipart);

//			send the message
            Transport.send(message);

            logger.debug(LOG_PREFIX + ": MESSAGE SENT SUCCESSFULLY");

            return true;

        } catch (Exception e) {
            logger.debug(LOG_PREFIX + ": MESSAGE NOT SENT. " + e.getLocalizedMessage());
            e.printStackTrace();
            return false;
        }

    }
306940
public static function userLogin($data, $loginField='email') {
		if( empty($data[$loginField]) )  {
			static::throwException('invalidLoginID');
		}
		$name = $data[$loginField];
		if( empty($data['password']) )  {
			static::throwException('invalidPassword');
		}
		$password = hashString($data['password']);
		//self::checkForEntry() does not return password and id now.
		
		$user = static::get(array(
// 			'where' => 'name LIKE '.static::formatValue($name),
			'where'		=> static::formatValue($name).' IN ('.implode(',', static::listLoginFields()).')',
			'number'	=> 1,
			'output'	=> SQLAdapter::OBJECT
		));
		if( empty($user) )  {
			static::throwException("invalidLoginID");
		}
		if( isset($user->published) && !$user->published )  {
			static::throwException('forbiddenLogin');
		}
		if( $user->password != $password )  {
			static::throwException('wrongPassword');
		}
		$user->logout();
		$user->login();
		return $user;
	}
502208
public function checkUserExistenceByEmail( $email, $parentGroupName = null )
    {
        /** @var \eZ\Publish\API\Repository\Repository $repository */
        $repository = $this->getRepository();
        $userService = $repository->getUserService();

        $existingUsers = $userService->loadUsersByEmail( $email );
        if ( count( $existingUsers ) == 0 )
        {
            return false;
        }

        if ( $parentGroupName )
        {
            foreach ( $existingUsers as $user )
            {
                $userGroups = $userService->loadUserGroupsOfUser( $user );
                foreach ( $userGroups as $userGroup )
                {
                    if ( $userGroup->getFieldValue( 'name' ) == $parentGroupName )
                        return true;
                }
            }
        }

        return false;
    }
586184
private function createUser($sendEmail = true)
	{
		$model = new RegisterForm;

		if (!empty($_POST))
		{
			$model->attributes = $_POST;

			// Save the user's information
			if ($model->save($sendEmail))
				return Users::model()->findByAttributes(array('email' => $_POST['email']))->getAPIAttributes(array('password'), array('role', 'metadata'));
			else
				return $this->returnError(400, NULL, $model->getErrors());
		}

		throw new CHttpException(400, Yii::t('Api.user', 'An unexpected error occured fulfilling your request.'));
	}
934889
public void sessionAttributeSet(ISession session, Object name, Object oldValue, Boolean oldIsListener, Object newValue, Boolean newIsListener) {
        _sessionStateEventDispatcher.sessionAttributeSet(session, name, oldValue, oldIsListener, newValue, newIsListener);

    }
1346939
public function loginUser($user = null, $properties = array())
    {
        if($this->_login_user && $user)
        {
            //Get the user data
            if(!is_array($user))
            {
                if($user instanceof UserInterface) {
                    $user = $user->toArray();
                } else {
                    $user = $this->getObject('user.provider')->getUser($user)->toArray();
                }
            }

            //Set the user properties
            $properties = array_merge($properties, (array) $user);

            $this->getObject('user')->setProperties($properties);
            $this->getObject('user')->setAuthentic();

            return true;
        }

        return false;
    }
847483
public function setEmail(string $email) : CNabuDataObject
    {
        if ($email === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$email")
            );
        }
        $this->setValue('nb_user_email', $email);
        
        return $this;
    }
1189873
protected void populateUser (
        User user, Username name, Password pass, String realname, String email, int siteId)
    {
        user.username = name.getUsername();
        user.setPassword(pass);
        user.setRealName(realname);
        user.setEmail(email);
        user.created = new Date(System.currentTimeMillis());
        user.setSiteId(siteId);
    }
919470
@Override
    public boolean login() throws LoginException {
        try{
            Object[] userPass= getCallBackAuth();
            if (null == userPass || userPass.length < 2) {
                setAuthenticated(false);
                throw new FailedLoginException();
            }
            String name = (String) userPass[0];
            Object pass = userPass[1];
            boolean authenticated = authenticate(name, pass);
            setAuthenticated(authenticated);

            if (!isAuthenticated()) {
                throw new FailedLoginException();
            }
            return isAuthenticated();
        } catch (UnsupportedCallbackException e) {
            throw new LoginException("Error obtaining callback information.");
        } catch (IOException e) {
            if (_debug) {
                e.printStackTrace();
            }
            throw new LoginException("IO Error performing login.");
        }
    }
1179348
private Session getSession(boolean isSingleton) {
		final MailAccount mailAccount = this.mailAccount;
		Authenticator authenticator = null;
		if (mailAccount.isAuth()) {
			authenticator = new UserPassAuthenticator(mailAccount.getUser(), mailAccount.getPass());
		}

		return isSingleton ? Session.getDefaultInstance(mailAccount.getSmtpProps(), authenticator) //
				: Session.getInstance(mailAccount.getSmtpProps(), authenticator);
	}
1339456
public function login($email, $password, $longsession = false) {
		$user = $this->getUserByEmail($email);
		if ($user == false) {
			BLog::addToLog('[Users]: login() wrong email!', LL_ERROR);
			return USERS_ERROR_NOSUCHEMAIL;
		}
		if ($user->active == USER_STATUS_NOTACTIVATED) {
			BLog::addToLog('[Users]: Not Activated', LL_ERROR);
			return USERS_ERROR_NOACTIVATED;
		}
		if ($user->active == USER_STATUS_BANNED) {
			BLog::addToLog('[Users]: Banned user', LL_ERROR);
			return USERS_ERROR_BANNED;
		}
		$hash = $this->makepass($email, $password);
		if ($user->password != $hash) {
			BLog::addToLog('[Users]: password hashes not equal! user hash=' . $user->password . '; post hash=' . $hash, LL_ERROR);
			return USERS_ERROR_PASS;
		}
		$options = array('interval' => $longsession ? 2592000 : 10800, 'updatestep' => 60,);
		$sess = BUsersSession::getInstance();
		$sess->newSession($user->id, $options);
		return USERS_ERROR_OK;
	}
714873
public function setEmail(string $email) : CNabuDataObject
    {
        $value = parent::setEmail(strtolower($email));

        return $value;
    }
397143
@SuppressWarnings("unchecked")
    protected void setDeliveryStatus(SMTPClientSession session) throws SMTPException {
        SMTPClientFutureImpl<Collection<FutureResult<Iterator<DeliveryRecipientStatus>>>> future = (SMTPClientFutureImpl<Collection<FutureResult<Iterator<DeliveryRecipientStatus>>>>) session.getAttribute(FUTURE_KEY);
        List<DeliveryRecipientStatus> statusList = (List<DeliveryRecipientStatus>) session.getAttribute(DELIVERY_STATUS_KEY);
        List<FutureResult<Iterator<DeliveryRecipientStatus>>> resultList = ((List<FutureResult<Iterator<DeliveryRecipientStatus>>>) session.getAttribute(DELIVERY_RESULT_LIST_KEY));
        Iterator<SMTPDeliveryEnvelope> transactions = ((Iterator<SMTPDeliveryEnvelope>) session.getAttribute(SMTP_TRANSACTIONS_KEY));

        resultList.add(new DeliveryResultImpl(statusList));
        
        if (!transactions.hasNext()) {
            future.setResult(resultList);

            next(session, SMTPRequestImpl.quit());
        } else {
            initSession(session);
            if (session.getSupportedExtensions().contains(PIPELINING_EXTENSION) && ((SMTPDeliveryAgentConfig)session.getConfig()).getPipeliningMode() != PipeliningMode.NO) {
                pipelining(session);
            } else {
                String sender = ((SMTPDeliveryEnvelope) session.getAttribute(CURRENT_SMTP_TRANSACTION_KEY)).getSender();

                next(session, SMTPRequestImpl.mail(sender));
            }
        }

    }
1173956
public static function _Login ($email, $password)
	{
		
		// Authenticate
		
		if (static::_Authenticate ($email, $password) !== TRUE)
		{
			return 'authentication_fail';
		}
		
		// Get user
		
		$user	= static::_readFromEmail ($email);
		
		if (!$user)
		{
			return 'invalid_user';
		}
		
		// Reset password
		
		$user->reset ('password');
		
		// Set timestamps
		
		$user->loginTimestamp	= time ();
		$user->lastAction		= $user->loginTimestamp;
		
		// Set session
		
		$user->setSessionData ();
		
		// Return user object
		
		return $user;
		
	}
564410
function send_message($eventdata){
        global $CFG;

        // Skip any messaging of suspended and deleted users.
        if ($eventdata->userto->auth === 'nologin' or $eventdata->userto->suspended or $eventdata->userto->deleted) {
            return true;
        }

        if (!empty($CFG->noemailever)) {
            // hidden setting for development sites, set in config.php if needed
            debugging('$CFG->noemailever is active, no jabber message sent.', DEBUG_MINIMAL);
            return true;
        }

        if (PHPUNIT_TEST) {
            // No connection to external servers allowed in phpunit tests.
            return true;
        }

        //hold onto jabber id preference because /admin/cron.php sends a lot of messages at once
        static $jabberaddresses = array();

        if (!array_key_exists($eventdata->userto->id, $jabberaddresses)) {
            $jabberaddresses[$eventdata->userto->id] = get_user_preferences('message_processor_jabber_jabberid', null, $eventdata->userto->id);
        }
        $jabberaddress = $jabberaddresses[$eventdata->userto->id];

        //calling s() on smallmessage causes Jabber to display things like &lt; Jabber != a browser
        $jabbermessage = fullname($eventdata->userfrom).': '.$eventdata->smallmessage;

        if (!empty($eventdata->contexturl)) {
            $jabbermessage .= "\n".get_string('view').': '.$eventdata->contexturl;
        }

        $jabbermessage .= "\n(".get_string('noreply','message').')';

        $conn = new XMPPHP_XMPP($CFG->jabberhost,$CFG->jabberport,$CFG->jabberusername,$CFG->jabberpassword,'moodle',$CFG->jabberserver);

        // No need to track the presence during the sending message process.
        $conn->track_presence = false;

        try {
            //$conn->useEncryption(false);
            $conn->connect();
            $conn->processUntil('session_start');
            $conn->presence();
            $conn->message($jabberaddress, $jabbermessage);
            $conn->disconnect();
        } catch(XMPPHP_Exception $e) {
            debugging($e->getMessage());
            return false;
        }
        return true;
    }