本文整理汇总了PHP中sfGuardUser::getUndisplayedLoginMessages方法的典型用法代码示例。如果您正苦于以下问题:PHP sfGuardUser::getUndisplayedLoginMessages方法的具体用法?PHP sfGuardUser::getUndisplayedLoginMessages怎么用?PHP sfGuardUser::getUndisplayedLoginMessages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfGuardUser
的用法示例。
在下文中一共展示了sfGuardUser::getUndisplayedLoginMessages方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: signIn
/**
* Signs in the user on the application.
*
* @param sfGuardUser $user The sfGuardUser id
* @param boolean $remember Whether or not to remember the user
* @param Doctrine_Connection $con A Doctrine_Connection object
*/
public function signIn($user, $auth_key = null, $con = null)
{
// signin
$this->setApiUserid($user->getId());
$this->setAuthenticated(true);
$this->clearCredentials();
$this->addCredentials($user->getAllPermissionNames());
// save last login
$user->setLastLogin(date('Y-m-d H:i:s'));
$user->save($con);
// Set login messages
$message = array();
foreach ($user->getUndisplayedLoginMessages() as $message) {
$messages[] = $message->getMessage();
$message->setDisplayed(true);
$message->save();
}
if (count($message) > 0) {
$this->setFlash('login', $messages);
}
// remember?
if ($auth_key) {
$this->setApiAuthkey($auth_key);
$api_key = sfConfig::get('app_web_app_api_key');
$api = ApiKeyTable::getInstance()->findOneBy('api_key', $api_key);
$auth_key = sfGuardUserAuthKeyTable::getInstance()->getMostRecentValidByApiKeyIdAndAuthKey($api->getIncremented(), $auth_key);
$expires = strtotime($auth_key->getExpiresAt());
// make key as a cookie
$remember_cookie = sfConfig::get('app_sf_guard_plugin_remember_cookie_name', 'sfRemember');
sfContext::getInstance()->getResponse()->setCookie($remember_cookie, $auth_key->getAuthKey(), $expires);
}
}