/** * 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); } }