18 protected bool $ignore_access =
false;
22 protected bool $show_disabled_entities =
false;
50 return $this->ignore_access;
61 $prev = $this->ignore_access;
62 $this->ignore_access = $ignore;
73 return $this->show_disabled_entities;
84 $prev = $this->show_disabled_entities;
85 $this->show_disabled_entities = $show;
102 $user = $this->getLoggedInUser();
105 if (!
$user instanceof \ElggUser) {
109 $this->session->set(
'__user_token', $this->generateUserToken(
$user));
122 $session_token = $this->session->get(
'__user_token');
123 $user_token = $this->generateUserToken($user);
125 if ($session_token !== $user_token) {
142 ],
'sha256', $user->password_hash);
144 return $hmac->getToken();
159 throw new LoginException($this->translator->translate(
'LoginException:BannedUser'));
163 $first_login = empty($user->last_login);
165 $this->events->triggerSequence(
'login',
'user', $user,
function(\
ElggUser $user) use (
$persistent) {
170 $this->setLoggedInUser($user,
true);
171 $this->setUserToken($user);
174 $this->translator->registerTranslations(\
Elgg\Project\
Paths::elgg() .
'languages/');
178 $this->persistent_login->makeLoginPersistent($user);
182 $this->session->migrate();
192 $this->removeLoggedInUser();
194 throw new LoginException($this->translator->translate(
'LoginException:DisabledUser'));
199 throw new LoginException($this->translator->translate(
'LoginException:Unknown'));
203 $this->events->trigger(
'login:first',
'user', $user);
204 $user->first_login = time();
215 $user = $this->getLoggedInUser();
220 if (!$this->events->triggerBefore(
'logout',
'user',
$user)) {
224 $this->persistent_login->removePersistentLogin();
227 $old_msg = $this->session->get(SystemMessagesService::SESSION_KEY, []);
228 $this->session->invalidate();
230 $this->logged_in_user = null;
232 $this->session->set(SystemMessagesService::SESSION_KEY, $old_msg);
234 $this->events->triggerAfter(
'logout',
'user',
$user);
249 $current_user = $this->getLoggedInUser();
250 if ($current_user != $user) {
251 if (!isset($migrate)) {
256 $this->session->migrate(
true);
259 $this->session->set(
'guid', $user->guid);
260 $this->logged_in_user =
$user;
261 $this->session_cache->clear();
262 $this->entity_cache->save($user);
263 $this->translator->setCurrentLanguage($user->language);
275 return $this->logged_in_user;
284 $user = $this->getLoggedInUser();
294 $user = $this->getLoggedInUser();
305 return (
bool) $this->getLoggedInUser();
315 $this->logged_in_user = null;
316 $this->session->remove(
'guid');
317 $this->session_cache->clear();
getLoggedInUser()
Gets the logged in user.
elgg_is_logged_in()
Returns whether or not the user is currently logged in.
Generic parent class for login exceptions.
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition plus the scripts used to control compilation and installation of the executable as a special the source code distributed need not include anything that is normally and so on of the operating system on which the executable unless that component itself accompanies the executable If distribution of executable or object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place counts as distribution of the source even though third parties are not compelled to copy the source along with the object code You may not or distribute the Program except as expressly provided under this License Any attempt otherwise to sublicense or distribute the Program is void
login(\ElggUser $user, bool $persistent=false)
Log in a user.
isAdminLoggedIn()
Returns whether or not the viewer is currently logged in and an admin user.
logout()
Log the current user out.
setLastLogin()
Sets the last logon time of the user to right now.
getDisabledEntityVisibility()
Are disabled entities shown?
removeLoggedInUser()
Remove the logged in user.
setUserToken(\ElggUser $user=null)
Set a user specific token in the session for the currently logged in user.
isLoggedIn()
Returns whether or not the user is currently logged in.
setDisabledEntityVisibility(bool $show=true)
Include disabled entities in queries.
Throw when a Security Exception occurs.
if(empty($entity_guid)||empty($recipient)||empty($muted_settings)||empty($hmac_token)) $hmac
static isCli()
Is application running in CLI.
Volatile cache for entities.
validateUserToken(\ElggUser $user)
Validate the user token stored in the session.
getLoggedInUserGuid()
Return the current logged in user by guid.
isEnabled()
Is this entity enabled?
__construct(protected\ElggSession $session, protected EventsService $events, protected Translator $translator, protected PersistentLoginService $persistent_login, protected SessionCache $session_cache, protected EntityCache $entity_cache)
Constructor.
if(isset($_COOKIE['elggperm'])) $session
setLoggedInUser(\ElggUser $user, bool $migrate=null)
Sets the logged in user.
setIgnoreAccess(bool $ignore=true)
Set ignore access.
_elgg_services()
Get the global service provider.
getIgnoreAccess()
Get current ignore access setting.
isBanned()
Is this user banned or not?
Login as the specified user.
generateUserToken(\ElggUser $user)
Generate a token for a specific user.