Checks if the user credentials matches the credentials stored
in the config

@param $user
331368
protected function loginUser($user)
    {
        $this->session->put(
            config('pagekit.session_key', 'pagekit_session'), [
                'github_id' => $user->id,
                'github_name' => $user->name,
                'github_email' => $user->email
            ]
        );
            $this->session->save();

    }
465827
public function validate(IUser $user): bool
    {
        if (null === $password = make(IPasswordRepository::class)->getByUser($user)) {
            return false;
        }

        return make(IPasswordHandler::class)->verify($this->password, $password->value());
    }
852257
public static function credentialsGrant($user) {  
        $config = require(Dir::config());
        $auth = $config['auth']; 
        $time = time();
        $token = [
            'iat' => $time, 
            'exp' => $time + (60*60), 
            'data' => [ 
                'user' => $user
            ]
        ];
        
        return JWT::encode($token, $auth['key']);     
    }
92367
public function actionConfirmPasswordHistory($user, $password)
    {
        $user = $this->getUser($user);
        $passwordHistory = $user->passwordHistories;
        $passwordInHistory = 0;
        foreach ($passwordHistory as $pass) {
            if ($pass->validatePassword($password)) {
                $passwordInHistory++;
                echo "This password was created at " . $pass->getCreatedAt() . ".\n";
            }
        }
        if ($passwordInHistory) {
            echo "$passwordInHistory matched.\n";
            return static::EXIT_CODE_NORMAL;
        }
        echo "No password matched.\n";
        return static::EXIT_CODE_ERROR;
    }
1050707
public function validateCredentials(UserContract $user, array $credentials): bool
    {
        $plain = $credentials['password'];
        $hashed = $user->getAuthPassword();

        if (\strlen($hashed) === 0) {
            return false;
        }

        return \password_verify($plain, $hashed) || $this->hasher->check($plain, $hashed);
    }
131707
public function deleteUser(User $user, string $password) : bool {
		if ($user->doesPasswordMatch($password)) {
			$stmt = $this->db->prepare(
				"DELETE FROM accounts " .
				"WHERE id=? AND username=? AND email=?;"
			);
			$stmt->bind_param("iss",
				$user->id, $user->username, $user->email);
			$stmt->execute();
			$this->db->commit();
			return true;
		} else {
			return false;
		}
	}
251078
private function hasOpenEmailValidation(User $user)
    {
        $ts = $user->email_verification_token_timestamp;
        if (!empty($ts) && (time() - $this->module->emailVerificationTokenExpirationTime) <= $ts) {
            return true;
        }
        
        return false;
    }
1141988
public function has(User $user)
    {
        return $this->entries->exists(
            function ($key, $entry) use ($user) {
                return $entry->getUser()->getId() === $user->getId();
            }
        );
    }
245006
public function setUser($user)
    {
        if ($user instanceof User) {
            $this->_user = $user;
            return true;
        }
        $this->_user = null;
        return false;
    }
178142
public function set_user($user)
    {
        if (is_object($user)) {
            $this->user = $user;

            // overwrite config with user preferences
            $this->config->set_user_prefs((array)$this->user->get_prefs());
        }
    }
236084
public function hasPassword(\Gems_User_User $user)
    {
        $sql = "SELECT CASE WHEN gup_password IS NULL THEN 0 ELSE 1 END FROM gems__user_passwords WHERE gup_id_user = ?";

        return (boolean) $this->db->fetchOne($sql, $user->getUserLoginId());
    }
303066
public function connectUserWithExistingCustomer($user, $customer)
    {
        $result = false;
        if ($user->getEmail() === $customer->getEmail()) {
            \call_user_func(
                [$customer->getAttribute(), 'set' . ucfirst($user->getType()) . 'Identity'],
                $user->getId()
            );
            $result = $this->udapteCustomerAttributes($customer);
        }

        return $result;
    }
47270
protected function _check(array $user, array $params) {
		if ($this->getConfig('includeAuthentication') && $this->_isPublic($params)) {
			return true;
		}

		if (!$user) {
			return false;
		}

		if ($this->getConfig('superAdmin')) {
			$superAdminColumn = $this->getConfig('superAdminColumn');
			if (!$superAdminColumn) {
				$superAdminColumn = $this->getConfig('idColumn');
			}
			if (!isset($user[$superAdminColumn])) {
				throw new Exception('Missing super Admin Column in user table');
			}
			if ($user[$superAdminColumn] === $this->getConfig('superAdmin')) {
				return true;
			}
		}

		// Give any logged in user access to ALL actions when `allowUser` is
		// enabled except when the `adminPrefix` is being used.
		if ($this->getConfig('allowUser')) {
			if (empty($params['prefix'])) {
				return true;
			}
			if ($params['prefix'] !== $this->getConfig('adminPrefix')) {
				return true;
			}
		}

		$userRoles = $this->_getUserRoles($user);

		// Allow access to all prefixed actions for users belonging to
		// the specified role that matches the prefix.
		if ($this->getConfig('authorizeByPrefix') && !empty($params['prefix'])) {
			if (in_array($params['prefix'], $this->getConfig('prefixes'))) {
				$roles = $this->_getAvailableRoles();
				$role = isset($roles[$params['prefix']]) ? $roles[$params['prefix']] : null;
				if ($role && in_array($role, $userRoles)) {
					return true;
				}
			}
		}

		// Allow logged in super admins access to all resources
		if ($this->getConfig('superAdminRole')) {
			foreach ($userRoles as $userRole) {
				if ((string)$userRole === (string)$this->getConfig('superAdminRole')) {
					return true;
				}
			}
		}

		if ($this->_acl === null) {
			$this->_acl = $this->_getAcl($this->getConfig('aclFilePath'));
		}

		// Allow access if user has a role with wildcard access to the resource
		$iniKey = $this->_constructIniKey($params);
		if (isset($this->_acl[$iniKey]['actions']['*'])) {
			$matchArray = $this->_acl[$iniKey]['actions']['*'];
			foreach ($userRoles as $userRole) {
				if (in_array((string)$userRole, $matchArray)) {
					return true;
				}
			}
		}

		// Allow access if user has been granted access to the specific resource
		if (isset($this->_acl[$iniKey]['actions'])) {
			if (array_key_exists($params['action'], $this->_acl[$iniKey]['actions']) && !empty($this->_acl[$iniKey]['actions'][$params['action']])) {
				$matchArray = $this->_acl[$iniKey]['actions'][$params['action']];
				foreach ($userRoles as $userRole) {
					if (in_array((string)$userRole, $matchArray)) {
						return true;
					}
				}
			}
		}
		return false;
	}
65749
function is_user_configured($user = null) {
        global $USER;

        if (is_null($user)) {
            $user = $USER;
        }
        return (bool)get_user_preferences('message_processor_jabber_jabberid', null, $user->id);
    }
104629
public static function changeUser($user)
    {
        $currentUser = self::getCurrentUser();

        if ($currentUser != $user) {
            $user = posix_getpwnam($user);
            if ($user) {
                posix_setuid($user['uid']);
                posix_setgid($user['gid']);
            }
        }
    }
785500
public function verifyPassword(User $user, string $password): bool
    {
        $this->enforcePasswordStrength($password);

        $auth = $this->authenticationProvider->findByUserId($user->getId());
        if (!$auth) {
            throw new NoSuchUserException();
        }

        return password_verify($password, $auth->getHash());
    }
956084
public function passwordMatches($password, $user)
    {
        if (!is_array($user)) {
            $user = $this->get($user);
        }

        if (empty($user['hash'])) {
            return false;
        }

        return gplcart_string_equals($user['hash'], gplcart_string_hash($password, $user['hash'], 0));
    }