本文整理汇总了PHP中UserSession::save方法的典型用法代码示例。如果您正苦于以下问题:PHP UserSession::save方法的具体用法?PHP UserSession::save怎么用?PHP UserSession::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserSession
的用法示例。
在下文中一共展示了UserSession::save方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testIndexNoAdmin
public function testIndexNoAdmin()
{
$s = new UserSession('azerty', 'azerty');
$s->save();
$this->request('admin');
$this->assertRedirected('');
$this->assertFlashError('You don\'t have the rights to view this page');
}
示例2: createForUser
/**
* @param $user User
* @param $sessionOnly boolean
* @param null $expireDate int
* @return UserSession
*/
public static function createForUser($user, $expireDate)
{
$session = new UserSession();
$session->user = $user->id;
$session->token = Auth::generateSessionToken($user->salt);
$session->createDate = Database::now();
$session->expireDate = CommonUtil::sqlTimeStamp($expireDate);
$session->expired = 0;
$session->save();
return $session;
}
示例3: executeLogin
/**
* @post
*/
public function executeLogin($username, $password, $redirect = '/')
{
$session = new UserSession($username, $password);
try
{
$session->save();
$this->notice(t('You are now logged in'));
$this->redirect($redirect);
}
catch (ValidationException $e)
{
$this->error(t('You are not logged in'));
$this->redirect = $redirect;
$this->session = $session;
$this->render('login');
}
}
示例4: checkAuthentication
public function checkAuthentication()
{
$this->user = null;
if (isset($_COOKIE[$this->cookie_name])) {
$arr = explode('-', $_COOKIE[$this->cookie_name]);
$session_id = intval($arr[0]);
$session_token = $arr[1];
}
if (isset($session_id)) {
$this->session = new UserSession($this->db, $session_id);
if (isset($this->session) && $this->session->is_loaded && Authentication::verifyPassword($session_token, $this->session->val('user_session_token_hash'))) {
$expires = time() + Authentication::$session_expire;
$session = new UserSession($this->db);
$session->data['user_session_id'] = $session_id;
$session->data['user_session_expires'] = SqlQuery::mysqlTimestamp($expires);
$session->save();
setcookie($this->cookie_name, $this->session->val('user_session_id') . '-' . $session_token, $expires, '/', false, false);
$this->user = new User($this->db, $this->session->val('user_session_user_id'));
$this->updateLastAccess();
}
}
}
示例5: doLogin
/**
* @remotable
* @formHandler
*/
public function doLogin($params)
{
$userName = $params['login'];
$isDesktop = false;
if (isset($params['isdesktop'])) {
$isDesktop = true;
}
$this->setSessionValue('isDesktop', $isDesktop);
$q = Doctrine_Query::create()->select("u.*")->from("User u")->where('u.login = ?', $userName)->andWhere('u.isActive = ?', 1);
$user = $q->fetchOne();
if (isset($params['password'])) {
$success = $user != null && $user->password == $this->generateHash($params['password']);
} else {
$success = $user != null && $user->devicePin == $params['devicePin'];
}
if ($success) {
//detect environments and set debug: 0:false/debug off 1:true/debug on
$fullPath = $_SERVER["REQUEST_URI"];
if (stristr($fullPath, "uat")) {
$userSession->debug = 1;
} elseif (stristr($fullPath, "moqoldWeb")) {
$userSession->debug = 1;
} else {
$userSession->debug = 0;
}
$this->setSessionValue('user', $user->ID);
$this->setSessionValue('userRole', $user->userRoleID);
$this->setSessionValue('contactID', $user->contactID);
$userSession = new UserSession();
$userSession->userID = $user->ID;
$userSession->hostIP = $this->getRealIpAddr();
$userSession->userAgent = $_SERVER['HTTP_USER_AGENT'];
//$userSession->refererName = -- useless in AJAX apps
$userSession->startTime = $this->getDateFormat();
$userSession->endTime = $userSession->startTime;
$userSession->save();
$this->setSessionValue('sessionId', $userSession->ID);
}
return $this->isLoggedIn($isDesktop);
}
示例6: login
private function login($u)
{
$s = new UserSession($u, $u);
$s->save();
}
示例7: login
private function login($name)
{
$s = new UserSession($name, $name);
$s->save();
}
示例8: login
private function login($user = 'dvorak')
{
$s = new UserSession($user, $user);
$s->save();
}
示例9: login
private function login($u = 'nathan')
{
$session = new UserSession($u, $u);
$session->save();
}
示例10: testModelsNoAdmin
public function testModelsNoAdmin()
{
$s = new UserSession('azerty', 'azerty');
$s->save();
$modules = Admin::modules();
$this->assertNull($modules);
$s->delete();
$modules = Admin::modules();
$this->assertNull($modules);
}
示例11: testUserLocked
public function testUserLocked()
{
$user = new User;
$user->username = 'someuser';
$user->email = 'someuser@somemail.com';
$user->password = 'thepass';
$user->passwordConfirmation = 'thepass';
$key = $user->save();
$session = new UserSession('someuser', 'thepass');
try
{
$session->save();
$this->fail('Expected exception');
}
catch (ValidationException $e)
{
$this->assertEquals('User is not activated',
$session->username_error);
}
}