/** * @param User $user * @param string $source * @param boolean $rememberMe * @return boolean */ protected function checkUserLogin(User $user, $source, $rememberMe) { if ($user->status == User::STATUS_NEW) { if (is_null($user->lastconfirmationmail_date) || $user->lastconfirmationmail_date < date('Y-m-d H:i:s', strtotime('-5 minutes'))) { // if confirmation email was older than 5 minutes then allow it to resend it User::$allowConfirmationEmailResend = true; if (isset($_POST['resend'])) { $user->resendConfirmationEmail(); } } if (!isset($_POST['resend'])) { Messages::get()->error('Email address was not yet confirmed! Check your emails and access received link to activate the account!'); } return false; } if ($user->status == User::STATUS_BLOCKED) { Messages::get()->error('This account has been banned! Please contact an admin if you think this is a mistake!'); return false; } if ($user->status == User::STATUS_DELETED) { Messages::get()->error('This account has been recently deleted! If you want to recover it please contact an admin. An account is permanently removed ' . User::DELETE_ACCOUNT_AFTER_X_DAYS . ' days after it was deleted!'); return false; } $this->connected = true; $this->setState('id', $user->id); $this->setState('name', $user->name); $this->setState('email', $user->email); $this->setState('icon', $user->icon ?: 'default.png'); $this->setState('status', $user->status); $this->setState('title', $user->title ? $user->title->title : '- no title -'); if ($user->joinuser_id) { $all = User::findAllByAttributes(['joinuser_id' => $user->joinuser_id]); $this->setState('mergedIDs', ArrayHelper::get()->transform($all, 'id')); } $this->setRights($groups = $user->getGroupsList()); $this->debug("Saved groups: " . implode(", ", $groups)); $user->last_login = date('Y-m-d H:i:s'); $user->last_login_source = $source; $user->save(); if ($rememberMe) { Cookie::get()->set(App::get()->shortName . $this->cookieKey, $user->email, $this->cookieTimeout); } if (!trim($user->name)) { // fill last details if they were not already saved $this->debug('need auto register'); WebApp::get()->request()->setController('user'); WebApp::get()->request()->setAction('registerauto'); } return true; }
public function setLimitPerPage($limit) { $this->perPage = $limit; if ($this->perPageSessionKey) { Session::get()->set($this->perPageSessionKey, $limit); } if ($this->perPageCookieKey) { Cookie::get()->set($this->perPageCookieKey, $limit); } }
/** * Logout for current user. It wil clear session and cookie. */ public function logout() { $this->_userData = array(); $this->_rights = array(); $this->connected = false; Session::get()->delete(App::get()->shortName . $this->sessionKey); Cookie::get()->delete(App::get()->shortName . $this->cookieKey); Cookie::get()->delete($this->cookieKey); session_destroy(); }