Merge pull request #57224 from nextcloud/jtr/docs-iusersession
Some checks are pending
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
Integration sqlite / changes (push) Waiting to run
Integration sqlite / integration-sqlite (master, 8.4, main, --tags ~@large files_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (master, 8.4, main, capabilities_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (master, 8.4, main, collaboration_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (master, 8.4, main, comments_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (master, 8.4, main, dav_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (master, 8.4, main, features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (master, 8.4, main, federation_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (master, 8.4, main, file_conversions) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (master, 8.4, main, files_reminders) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (master, 8.4, main, filesdrop_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (master, 8.4, main, ldap_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (master, 8.4, main, openldap_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (master, 8.4, main, openldap_numerical_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (master, 8.4, main, remoteapi_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (master, 8.4, main, routing_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (master, 8.4, main, setup_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (master, 8.4, main, sharees_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (master, 8.4, main, sharing_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (master, 8.4, main, theming_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (master, 8.4, main, videoverification_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite-summary (push) Blocked by required conditions
Psalm static code analysis / static-code-analysis (push) Waiting to run
Psalm static code analysis / static-code-analysis-security (push) Waiting to run
Psalm static code analysis / static-code-analysis-ocp (push) Waiting to run
Psalm static code analysis / static-code-analysis-ncu (push) Waiting to run

docs(IUserSession): Improve interface docs
This commit is contained in:
Andy Scherzinger 2025-12-23 13:12:20 +01:00 committed by GitHub
commit f791d91c00
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,33 +1,35 @@
<?php
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016-2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
// use OCP namespace for all classes that are considered public.
// This means that they should be used by apps instead of the internal Nextcloud classes
namespace OCP;
/**
* User session
* Interface for managing and querying user session state.
*
* Provides methods for authenticating users, accessing the active user,
* and handling login/logout functionality in a Nextcloud server session.
* @since 6.0.0
*/
interface IUserSession {
/**
* Do a user login
* Attempts to authenticate the given user and start a session.
*
* @param string $uid the username
* @param string $password the password
* @return bool true if successful
* @param string $uid The user's unique identifier (username).
* @param string $password The user's plain-text password.
* @return bool True on successful login, false otherwise.
* @since 6.0.0
*/
public function login($uid, $password);
/**
* Logs the user out including all the session data
* Logout, destroys session
* Logs out the current user and terminates their session.
*
* Clears authentication tokens and user-related session data.
*
* @return void
* @since 6.0.0
@ -35,48 +37,58 @@ interface IUserSession {
public function logout();
/**
* set the currently active user
* Sets the current active user for this session.
*
* @param \OCP\IUser|null $user
* Pass null to clear the active user and log out any existing session.
*
* @param \OCP\IUser|null $user The user to set as active, or null to unset.
* @since 8.0.0
*/
public function setUser($user);
/**
* Temporarily set the currently active user without persisting in the session
* Temporarily sets the active user for this session without persisting it in the session storage.
*
* @param IUser|null $user
* Useful for request-scoped user overrides that do not affect the actual session state.
*
* @param \OCP\IUser|null $user The user to set as active, or null to clear.
* @since 29.0.0
*/
public function setVolatileActiveUser(?IUser $user): void;
/**
* get the current active user
* Returns the currently authenticated user for this session, or null if the session has no active user.
*
* @return \OCP\IUser|null Current user, otherwise null
* @return \OCP\IUser|null The active user, or null if the session is anonymous, expired, or in incognito mode.
* @since 8.0.0
*/
public function getUser();
/**
* Checks whether the user is logged in
* Checks whether a user is currently logged in for this session.
*
* @return bool if logged in
* @return bool True if a user is authenticated and enabled, false otherwise.
* @since 8.0.0
*/
public function isLoggedIn();
/**
* get getImpersonatingUserID
* Returns the user ID of the impersonator if another user is being impersonated.
*
* @return string|null
* @return string|null The impersonating user's ID, or null if not impersonating.
* @since 18.0.0
*/
public function getImpersonatingUserID(): ?string;
/**
* set setImpersonatingUserID
* Sets or clears the impersonator's user ID in the current session.
*
* Note: This does not initiate impersonation, but only records the identity of the impersonator in the session.
*
* If $useCurrentUser is true (default), records the current user's ID as the impersonator.
* If false, removes any impersonator information from the session.
*
* @param bool $useCurrentUser Whether to assign the current user as the impersonator or to clear it.
* @since 18.0.0
*/
public function setImpersonatingUserID(bool $useCurrentUser = true): void;