本文整理汇总了PHP中AgaviRequestDataHolder::getHeader方法的典型用法代码示例。如果您正苦于以下问题:PHP AgaviRequestDataHolder::getHeader方法的具体用法?PHP AgaviRequestDataHolder::getHeader怎么用?PHP AgaviRequestDataHolder::getHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AgaviRequestDataHolder
的用法示例。
在下文中一共展示了AgaviRequestDataHolder::getHeader方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: authenticate
/**
* Tries to authenticate the user with the given request data.
*
* @param AgaviRequestDataHolder $request_data
*
* @return string name of agavi view to select
*/
protected function authenticate(AgaviRequestDataHolder $request_data)
{
$translation_manager = $this->getContext()->getTranslationManager();
$user = $this->getContext()->getUser();
$auth_request = $request_data->getHeader('AUTH_REQUEST');
$username = $auth_request['username'];
$password = $auth_request['password'];
$service_locator = $this->getContext()->getServiceLocator();
$authentication_service = $service_locator->getAuthenticationService();
$auth_response = $authentication_service->authenticate($username, $password);
$log_message = sprintf("username='%s' message='%s' auth_provider='%s' errors=''", $username, $auth_response->getMessage(), get_class($authentication_service), join(';', $auth_response->getErrors()));
$log_message_part = sprintf("for username '{$username}' via auth provider %s.", get_class($authentication_service));
if ($auth_response->getState() === AuthResponse::STATE_AUTHORIZED) {
$view_name = 'Success';
$user->setAttributes(array_merge(['acl_role' => AclService::ROLE_NON_PRIV], $auth_response->getAttributes()));
$user->setAuthenticated(true);
$this->logInfo('[AUTHORIZED] ' . $log_message);
} elseif ($auth_response->getState() === AuthResponse::STATE_UNAUTHORIZED) {
$view_name = 'Error';
$user->setAuthenticated(false);
$this->setAttribute('errors', ['auth' => $translation_manager->_('invalid_login', 'honeybee.system_account.user.errors')]);
$this->logError('[UNAUTHORIZED] ' . $log_message);
} else {
$view_name = 'Error';
$user->setAuthenticated(false);
$this->setAttribute('errors', ['auth' => $auth_response->getMessage()]);
$vm->setError('invalid_login', $tm->_('invalid_login', 'honeybee.system_account.user.errors'));
$this->logError("[ERROR] state='" . $auth_response->getState() . "' " . $log_message);
}
return $view_name;
}