Session¶
-
class
OC\User\Session¶ - Class SessionHooks available in scope \OC\User:- preSetPassword(\OC\User\User $user, string $password, string $recoverPassword)- postSetPassword(\OC\User\User $user, string $password, string $recoverPassword)- preDelete(\OC\User\User $user)- postDelete(\OC\User\User $user)- preCreateUser(string $uid, string $password)- postCreateUser(\OC\User\User $user)- assignedUserId(string $uid)- preUnassignedUserId(string $uid)- postUnassignedUserId(string $uid)- preLogin(string $user, string $password)- postLogin(\OC\User\User $user, string $loginName, string $password, boolean $isTokenLogin)- preRememberedLogin(string $uid)- postRememberedLogin(\OC\User\User $user)- logout()- postLogout()
Source: lib/private/User/Session.php#92 Implements: OCP\IUserSessionOC\Hooks\Emitter
Properties¶
-
protected static property
OC\User\Session::$activeUser¶ Source: lib/private/User/Session.php#110 Type: \OC\User\User
Methods¶
-
public
OC\User\Session::__construct($manager, $session, $timeFactory, $tokenProvider, $config, $random, $lockdownManager, $logger, $dispatcher)¶ Source: Parameters: - $manager (
OC\User\Manager) - $session (
OCP\ISession) - $timeFactory (
OCP\AppFramework\Utility\ITimeFactory) - $tokenProvider (
OC\Authentication\Token\IProvider) - $config (
OCP\IConfig) - $random (
OCP\Security\ISecureRandom) - $lockdownManager (
OCP\Lockdown\ILockdownManager) - $logger (
OCP\ILogger)
- $manager (
-
public
OC\User\Session::setTokenProvider($provider)¶ Source: Parameters: - $provider (
OC\Authentication\Token\IProvider)
- $provider (
-
public
OC\User\Session::listen($scope, $method, $callback)¶ Source: Parameters: - $scope (string)
- $method (string)
- $callback (callable)
-
public
OC\User\Session::removeListener($scope=null, $method=null, $callback=null)¶ Source: Parameters: - $scope (string) optional
- $method (string) optional
- $callback (callable) optional
-
public
OC\User\Session::getManager()¶ - get the manager object
Source: lib/private/User/Session.php#184 Returns: \OC\User\Manager|\OC\Hooks\PublicEmitter
-
public
OC\User\Session::getSession()¶ - get the session object
Source: lib/private/User/Session.php#193 Returns: \OCP\ISession
-
public
OC\User\Session::setSession($session)¶ - set the session object
Source: Parameters: - $session (
OCP\ISession)
- $session (
-
public
OC\User\Session::setUser($user)¶ - set the currently active user
Source: Parameters: - $user (
OCP\IUser| null)
- $user (
-
public
OC\User\Session::getUser()¶ - get the current active user
Source: lib/private/User/Session.php#229 Returns: \OCP\IUser| null Current user, otherwise null
-
protected
OC\User\Session::validateSession()¶ - Validate whether the current session is valid- For token-authenticated clients, the token validity is checked- For browsers, the session token validity is checked
Source: lib/private/User/Session.php#255
-
public
OC\User\Session::isLoggedIn()¶ - Checks whether the user is logged in
Source: lib/private/User/Session.php#280 Returns: bool if logged in
-
public
OC\User\Session::setLoginName($loginName)¶ - set the login name
Source: Parameters: - $loginName (string | null) for the logged in user
-
public
OC\User\Session::getLoginName()¶ - get the login name of the current user
Source: lib/private/User/Session.php#307 Returns: string
-
public
OC\User\Session::getImpersonatingUserID()¶ Source: lib/private/User/Session.php#324 Returns: null | string
-
public
OC\User\Session::setImpersonatingUserID($useCurrentUser=true)¶ Source: lib/private/User/Session.php#328
-
protected
OC\User\Session::setToken($token)¶ - set the token id
Source: Parameters: - $token (int | null) that was used to log in
-
public
OC\User\Session::login($uid, $password)¶ - try to log in with the provided credentials
Source: Parameters: - $uid (string)
- $password (string)
Returns: bool | null
Throws:
-
public
OC\User\Session::completeLogin($user, $loginDetails, $regenerateSessionId=true)¶ Source: Parameters: - $user (
OCP\IUser) - $loginDetails (array)
- $regenerateSessionId (bool)
Returns: bool returns true if login successful or an exception otherwise
Throws: - $user (
-
public
OC\User\Session::logClientIn($user, $password, $request, $throttler)¶ - Tries to log in a clientChecks token auth enforcedChecks 2FA enabled
Source: Parameters: - $user (string)
- $password (string)
- $request (
OCP\IRequest) - $throttler (
OC\Security\Bruteforce\Throttler)
Throws: Throws: \OC\Authentication\Exceptions\PasswordLoginForbiddenExceptionThrows: Throws: \OC\Authentication\Exceptions\PasswordLoginForbiddenExceptionReturns: bool
-
protected
OC\User\Session::supportsCookies($request)¶ Source: lib/private/User/Session.php#490
-
protected
OC\User\Session::isTwoFactorEnforced($username)¶ Source: lib/private/User/Session.php#502
-
public
OC\User\Session::isTokenPassword($password)¶ - Check if the given ‘password’ is actually a device token
Source: Parameters: - $password (string)
Returns: bool
Throws:
-
protected
OC\User\Session::prepareUserLogin($firstTimeLogin, $refreshCsrfToken=true)¶ Source: lib/private/User/Session.php#545
-
public
OC\User\Session::tryBasicAuthLogin($request, $throttler)¶ - Tries to login the user with HTTP Basic Authentication
Source: Parameters: - $request (
OCP\IRequest) - $throttler (
OC\Security\Bruteforce\Throttler)
Returns: bool if the login was successful
- $request (
-
public
OC\User\Session::createSessionToken($request, $uid, $loginName, $password=null, $remember=\OC\Authentication\Token\IToken::DO_NOT_REMEMBER)¶ - Create a new session token for the given user credentials
Source: Parameters: - $request (
OCP\IRequest) - $uid (string) user UID
- $loginName (string) login name
- $password (string)
- $remember (int)
Returns: bool
- $request (
-
public
OC\User\Session::tryTokenLogin($request)¶ - Tries to login the user with auth token header
Source: Parameters: - $request (
OCP\IRequest)
Returns: bool
- $request (
-
public
OC\User\Session::loginWithCookie($uid, $currentToken, $oldSessionId)¶ - perform login using the magic cookie (remember login)
Source: Parameters: - $uid (string) the username
- $currentToken (string)
- $oldSessionId (string)
Returns: bool
-
public
OC\User\Session::logout()¶ - logout the user from the session
Source: lib/private/User/Session.php#921
-
public
OC\User\Session::setMagicInCookie($username, $token)¶ - Set cookie value to use in next page load
Source: Parameters: - $username (string) username to be set
- $token (string)
-
public
OC\User\Session::unsetMagicInCookie()¶ - Remove cookie for “remember username”
Source: lib/private/User/Session.php#991
-
public
OC\User\Session::updateSessionTokenPassword($password)¶ - Update password of the browser session token if there is one
Source: Parameters: - $password (string)
-
public
OC\User\Session::updateTokens($uid, $password)¶ Source: lib/private/User/Session.php#1025