31 protected $ignore_access =
false;
46 protected $show_disabled_entities =
false;
82 $this->events = $events;
83 $this->translator = $translator;
84 $this->persistent_login = $persistent_login;
85 $this->session_cache = $session_cache;
86 $this->entity_cache = $entity_cache;
95 return $this->ignore_access;
106 $prev = $this->ignore_access;
107 $this->ignore_access = $ignore;
118 return $this->show_disabled_entities;
129 $prev = $this->show_disabled_entities;
130 $this->show_disabled_entities = $show;
147 $user = $this->getLoggedInUser();
150 if (!
$user instanceof \ElggUser) {
154 $this->session->set(
'__user_token', $this->generateUserToken(
$user));
167 $session_token = $this->session->get(
'__user_token');
168 $user_token = $this->generateUserToken($user);
170 if ($session_token !== $user_token) {
187 ],
'sha256', $user->password_hash);
189 return $hmac->getToken();
204 throw new LoginException($this->translator->translate(
'LoginException:BannedUser'));
208 if (!$this->events->triggerBefore(
'login',
'user', $user)) {
209 throw new LoginException($this->translator->translate(
'LoginException:Unknown'));
214 throw new LoginException($this->translator->translate(
'LoginException:DisabledUser'));
219 $this->setLoggedInUser($user);
220 $this->setUserToken($user);
223 $this->translator->registerTranslations(\
Elgg\Project\
Paths::elgg() .
'languages/');
227 $this->persistent_login->makeLoginPersistent($user);
231 $this->session->migrate();
234 $first_login = empty($user->last_login);
239 $this->events->triggerAfter(
'login',
'user', $user);
242 $this->events->trigger(
'login:first',
'user', $user);
243 $user->first_login = time();
254 $user = $this->getLoggedInUser();
259 if (!$this->events->triggerBefore(
'logout',
'user',
$user)) {
263 $this->persistent_login->removePersistentLogin();
266 $old_msg = $this->session->get(SystemMessagesService::SESSION_KEY, []);
267 $this->session->invalidate();
269 $this->logged_in_user = null;
271 $this->session->set(SystemMessagesService::SESSION_KEY, $old_msg);
273 $this->events->triggerAfter(
'logout',
'user',
$user);
286 $current_user = $this->getLoggedInUser();
287 if ($current_user != $user) {
288 $this->session->set(
'guid', $user->guid);
289 $this->logged_in_user =
$user;
290 $this->session_cache->clear();
291 $this->entity_cache->save($user);
292 $this->translator->setCurrentLanguage($user->language);
304 return $this->logged_in_user;
313 $user = $this->getLoggedInUser();
323 $user = $this->getLoggedInUser();
334 return (
bool) $this->getLoggedInUser();
344 $this->logged_in_user = null;
345 $this->session->remove(
'guid');
346 $this->session_cache->clear();
getLoggedInUser()
Gets the logged in user.
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
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?
if(isset($_COOKIE['elggperm'])) $session
__construct(\ElggSession $session, EventsService $events, Translator $translator, PersistentLoginService $persistent_login, SessionCache $session_cache, EntityCache $entity_cache)
Constructor.
setLoggedInUser(\ElggUser $user)
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.