Get the token for a user

@param string $userLogin Username
@param string $md5Password Password in clear text
@param array $optional
@return bool|object
@throws InvalidRequestException
777636
public function getTokenAuth($userLogin, $md5Password, array $optional = [])
    {
        return $this->_request('UsersManager.getTokenAuth', [
            'userLogin' => $userLogin,
            'md5Password' => md5($md5Password),
        ], $optional);
    }
106801
public function getFromLogin( $login){
        $rest = $this->getService( self::API_VPN_USER . $login);
        $rest->GET();

        return $rest->getResult( models\VPN\Server\User::class);
    }
1276317
public function getUserByLogin(string $login)
    {
        $retval = null;

        if (strlen($login) > 0) {
            $nb_user = CNabuUser::findByLogin($this, $login);
            if ($nb_user instanceof CNabuUser && $nb_user->validateCustomer($this)) {
                $nb_user->setCustomer($this);
                $retval = $nb_user;
            }
        }

        return $retval;
    }
811027
protected function authenticate($username, $password) {
        $authenticator=$this->config()->authenticator_class;
        
        $member=$authenticator::authenticate(array(
                                                $this->config()->authenticator_username_field=>$username,
                                                'Password'=>$password
                                            ));
        
        return (!empty($member) && $member!==false && $member->exists()==true && Permission::check('KAPOST_API_ACCESS', 'any', $member));
    }
441913
public function getUser($username, $password)
    {
        $authHash = $this->hashUserNameAndPassword($username, $password);
        $body     = json_encode(['clientType' => 'wp-plugin']);

        try {
            $response = $this->client->post(
              $this->loginurl, [
                'headers' => ['Authorization' => 'Basic ' . $authHash],
                'verify'  => $this->certFile,
                'body'    => $body //wp-plugin value makes session not expire
              ]);
            $this->response = $response->getBody();

        } catch (ClientException $e) {
            $response       = [
              'code'     => $e->getCode(),
              'response' => $e->getMessage(),
              'error'    => true
            ];
            $this->response = json_encode($response);

        } catch (ConnectException $e) {
            $message = 'Can not connect to Leadpages Server:';
            $response = $this->parseException($e, $message);
            $this->response = $response;
        }

        return $this;
    }
1272547
public function setUserPreference($userLogin, $preferenceName, $preferenceValue, array $optional = [])
    {
        return $this->_request('UsersManager.setUserPreference', [
            'userLogin' => $userLogin,
            'preferenceName' => $preferenceName,
            'preferenceValue' => $preferenceValue,
        ], $optional);
    }
845807
public function get_password_restriction_status($userpassword) {
        global $USER;
        if ($this->can_manage()) {
            return false;
        }

        if ($this->properties->usepassword && empty($USER->lessonloggedin[$this->id])) {
            $correctpass = false;
            if (!empty($userpassword) &&
                    (($this->properties->password == md5(trim($userpassword))) || ($this->properties->password == trim($userpassword)))) {
                // With or without md5 for backward compatibility (MDL-11090).
                $correctpass = true;
                $USER->lessonloggedin[$this->id] = true;
            } else if (isset($this->properties->extrapasswords)) {
                // Group overrides may have additional passwords.
                foreach ($this->properties->extrapasswords as $password) {
                    if (strcmp($password, md5(trim($userpassword))) === 0 || strcmp($password, trim($userpassword)) === 0) {
                        $correctpass = true;
                        $USER->lessonloggedin[$this->id] = true;
                    }
                }
            }
            return !$correctpass;
        }
        return false;
    }
976726
public function userLogin($username, $password)
    {
        return $this->requestHandler->sendRequestAsync('POST', 'api/v4/users/login/',
            [
                'form_params' => [
                    'username' => $username,
                    'password' => $password
                ]
            ])->then(
            function ($result) {
                $this->requestHandler->setAccessTokenCredentials($result['tokenKey'], $result['tokenSecret']);
                return $result;
            }
        );
    }
1240244
public function addUser($userLogin, $password, $email, $alias = '', array $optional = [])
    {
        return $this->_request('UsersManager.addUser', [
            'userLogin' => $userLogin,
            'password' => $password,
            'email' => $email,
            'alias' => $alias,
        ], $optional);
    }
366169
public User get(String loginname, String password) {
        Connection conn = null;
        User user = null;
        if (loginname == null || password == null) return null;
        String cryptpassword = MD5.encodeString(password,null);
        try {
            conn = ConnectionUtils.getConnection();
            user = userDAO.get(conn,loginname,cryptpassword);
        } catch(SQLException e) {
            logger.error(e.getMessage());
        } finally {
            DbUtils.closeQuietly(conn);
        }
        return user;
    }
285321
protected function loginByToken($username, \Espo\Entities\AuthToken $authToken = null)
    {
        if (!isset($authToken)) {
            return null;
        }

        $userId = $authToken->get('userId');
        $user = $this->getEntityManager()->getEntity('User', $userId);

        $tokenUsername = $user->get('userName');
        if (strtolower($username) != strtolower($tokenUsername)) {
            $GLOBALS['log']->alert('Unauthorized access attempt for user ['.$username.'] from IP ['.$_SERVER['REMOTE_ADDR'].']');
            return null;
        }

        $user = $this->getEntityManager()->getRepository('User')->findOne(array(
            'whereClause' => array(
                'userName' => $username,
            )
        ));

        return $user;
    }
18792
protected function acquireSecurityTokenFromFederatedSTS($username, $password) {

        $response = Requests::get(str_replace('{username}', $username, self::$RealmUrlTemplate),null);
        $federatedStsUrl = $this->getFederatedAuthenticationInformation($response);

        if ($federatedStsUrl) {
          $message_id = md5(uniqid($username . '-' . time() . '-' . rand() , true));
          $data = $this->prepareSecurityFederatedTokenRequest($username, $password, $message_id, $federatedStsUrl->textContent);

          $headers = array();
          $headers['Content-Type'] = 'application/soap+xml';
          $response = Requests::post($federatedStsUrl->textContent, $headers, $data);

          $samlAssertion = $this->getSamlAssertion($response);

          if ($samlAssertion) {
            $samlAssertion_node = $samlAssertion->item(0);
            $data = $this->prepareRST2Request($samlAssertion_node);
            $response = Requests::post(self::$RST2Url, $headers, $data);
            $this->usingFederatedSTS = TRUE;

            return $response;
          }
        }

        return NULL;
    }
456562
public function GetUserFromCache($UserToken, $TokenType) {
      if ($TokenType == 'name') {
         $UserNameKey = FormatString(self::USERNAME_KEY, array('Name' => md5($UserToken)));
         $UserID = Gdn::Cache()->Get($UserNameKey);
         
         if ($UserID === Gdn_Cache::CACHEOP_FAILURE) return FALSE;
         $UserToken = $UserID; $TokenType = 'userid';
      } else {
         $UserID = $UserToken;
      }
      
      if ($TokenType != 'userid') return FALSE;
      
      // Get from memcached
      $UserKey = FormatString(self::USERID_KEY, array('UserID' => $UserToken));
      $User = Gdn::Cache()->Get($UserKey);
      
      return $User;
   }
1004079
public function getUser($login)
	{
		if (strlen($login) < 1) {
			throw new InvalidArgumentException("Login can't be empty");
		}
		$client = new CouchClient($this->client->dsn(), $this->usersdb, $this->client->options());
		return $client->getDoc("org.couchdb.user:" . $login);
	}
1039114
public function authenticate($login, $password)
    {
        $defaultHttpHeaders                       = $this->defaultHttpHeaders;
        $this->defaultHttpHeaders['Content-Type'] = 'application/x-www-form-urlencoded';
        $this->setPostFields(http_build_query(['username' => $login, 'password' => $password]));
        $result                                   = $this->performRequest('authenticate',
            'POST', 'xml');
        $this->defaultHttpHeaders                 = $defaultHttpHeaders;
        if (!empty($result['message'])) {
            $this->addStatusMessage($result['message'],
                $result['success'] == 'true' ? 'success' : 'warning' );
        }
        return array_key_exists('success', $result) && $result['success'] == 'true';
    }
1015129
public static function login($userLogin, $userPassword)
    {
        try {
            $user = self::authenticate($userLogin, $userPassword);
            $loggedIn = self::startSession($user);
        } catch (common_user_auth_AuthFailedException $e) {
            $loggedIn = false;
        }
        return $loggedIn;
    }
262849
public function authenticate($credentials, $remember = false, $login = true)
    {
        $response = $this->fireEvent('sentinel.authenticating', $credentials, true);

        if ($response === false) {
            return false;
        }

        if ($credentials instanceof UserInterface) {
            $user = $credentials;
        } else {
            $user = $this->users->findByCredentials($credentials);

            $valid = $user !== null ? $this->users->validateCredentials($user, $credentials) : false;

            if ($user === null || $valid === false) {
                $this->cycleCheckpoints('fail', $user, false);

                return false;
            }
        }

        if (! $this->cycleCheckpoints('login', $user)) {
            return false;
        }

        if ($login === true) {
            $method = $remember === true ? 'loginAndRemember' : 'login';

            if (! $user = $this->{$method}($user)) {
                return false;
            }
        }

        $this->fireEvent('sentinel.authenticated', $user);

        return $this->user = $user;
    }