mirror of
https://github.com/friendica/friendica
synced 2025-04-27 12:30:11 +00:00
Adapt UserSession
- Move from App methods to UserSession methods - Deprecate corresponding App methods
This commit is contained in:
parent
c376605dd2
commit
bfc1c157f1
6 changed files with 62 additions and 46 deletions
|
@ -33,6 +33,13 @@ interface IHandleUserSessions extends IHandleSessions
|
|||
*/
|
||||
public function getLocalUserId();
|
||||
|
||||
/**
|
||||
* Returns the user nickname of locally logged-in user.
|
||||
*
|
||||
* @return string|false User's nickname or false
|
||||
*/
|
||||
public function getLocalUserNickname();
|
||||
|
||||
/**
|
||||
* Returns the public contact id of logged-in user or false.
|
||||
*
|
||||
|
@ -79,6 +86,13 @@ interface IHandleUserSessions extends IHandleSessions
|
|||
*/
|
||||
public function isAuthenticated(): bool;
|
||||
|
||||
/**
|
||||
* Check if current user has admin role.
|
||||
*
|
||||
* @return bool true if user is an admin
|
||||
*/
|
||||
public function isSiteAdmin(): bool;
|
||||
|
||||
/**
|
||||
* Returns User ID of the managed user in case it's a different identity
|
||||
*
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace Friendica\Core\Session\Model;
|
|||
use Friendica\Core\Session\Capability\IHandleSessions;
|
||||
use Friendica\Core\Session\Capability\IHandleUserSessions;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\User;
|
||||
|
||||
/**
|
||||
* This class handles user sessions, which is directly extended from regular session
|
||||
|
@ -50,6 +51,16 @@ class UserSession implements IHandleUserSessions
|
|||
return false;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public function getLocalUserNickname()
|
||||
{
|
||||
if ($this->isAuthenticated()) {
|
||||
return $this->session->get('nickname');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public function getPublicContactId()
|
||||
{
|
||||
|
@ -122,6 +133,12 @@ class UserSession implements IHandleUserSessions
|
|||
return $this->session->get('authenticated', false);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public function isSiteAdmin(): bool
|
||||
{
|
||||
return User::isSiteAdmin($this->getLocalUserId());
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public function setVisitorsContacts()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue