本文整理汇总了PHP中UserPeer::getAuthenticatedUser方法的典型用法代码示例。如果您正苦于以下问题:PHP UserPeer::getAuthenticatedUser方法的具体用法?PHP UserPeer::getAuthenticatedUser怎么用?PHP UserPeer::getAuthenticatedUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserPeer
的用法示例。
在下文中一共展示了UserPeer::getAuthenticatedUser方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Execute this validator.
*
* @param mixed A file or parameter value/array.
* @param error An error message reference.
*
* @return bool true, if this validator executes successfully, otherwise
* false.
*/
public function execute(&$value, &$error)
{
$actionName = $this->getContext()->getActionStack()->getFirstEntry()->getActionName();
if (isset($actionName) and 'add' == $actionName) {
$addError = $this->getContext()->getRequest()->getError('nickname');
if (isset($addError)) {
$error = $addError;
return false;
}
//see if there are other errors
if (count($this->getContext()->getRequest()->getErrorNames())) {
$error = null;
return false;
}
}
$password_param = $this->getParameterHolder()->get('password');
$password = $this->getContext()->getRequest()->getParameter($password_param);
$login = $value;
// anonymous is not a real user
if ($login == 'anonymous') {
$error = $this->getParameterHolder()->get('login_error');
return false;
}
if ($user = UserPeer::getAuthenticatedUser($login, $password)) {
$this->getContext()->getUser()->signIn($user);
return true;
}
$error = $this->getParameterHolder()->get('login_error');
return false;
}
示例2: authenticateUser
private function authenticateUser()
{
if (isset($_SERVER['PHP_AUTH_USER'])) {
if ($user = UserPeer::getAuthenticatedUser($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])) {
$this->getContext()->getUser()->signIn($user);
return $user;
}
}
header('WWW-Authenticate: Basic realm="askeet API"');
header('HTTP/1.0 401 Unauthorized');
}
示例3: execute
/**
* Execute this validator.
*
* @param mixed A file or parameter value/array.
* @param error An error message reference.
*
* @return bool true, if this validator executes successfully, otherwise
* false.
*/
public function execute(&$value, &$error)
{
$password_param = $this->getParameterHolder()->get('password');
$password = $this->getContext()->getRequest()->getParameter($password_param);
$login = $value;
// anonymous is not a real user
if ($login == 'anonymous') {
$error = $this->getParameterHolder()->get('login_error');
return false;
}
if ($user = UserPeer::getAuthenticatedUser($login, $password)) {
$this->getContext()->getUser()->signIn($user);
return true;
}
$error = $this->getParameterHolder()->get('login_error');
return false;
}
示例4: validateUser
/**
* Validates a user user login
*
* @param string $strUsername
* @param string $strPassword
* @param bool $bolSetLocal Optional. Stores the validated domain and user.
* Default is TRUE.
* @param bool $bolSetSession Optional. Sets the user session. Default is FALSE.
* @param bool $bolSetCookie Optional. Default is FALSE.
* @return User
*/
public function validateUser($strUsername, $strPassword = false, $bolSetLocal = true, $bolSetSession = false, $bolSetCookie = false, PropelPDO $con = null)
{
$defaultAccountName = \Xily\Config::get('app.account', 'string', '');
if ($defaultAccountName !== '' and strpos($strUsername, '/') === false) {
$strUsername = $defaultAccountName . '/' . $strUsername;
}
$user = UserPeer::getAuthenticatedUser($strUsername, $strPassword, $con);
if ($user === null or $user->getDeleted()) {
return null;
}
if ($bolSetLocal) {
$this->user = $user;
}
if ($bolSetSession) {
$this->setUserSession($user->getId());
}
if ($bolSetCookie) {
setcookie('autologin', $this->createCookieToken($user->getFQN($con), $this->cookieDuration), time() + 86400 * $this->cookieDuration);
}
return $user;
}