|
1 | 1 | <?php |
2 | 2 |
|
3 | 3 | /** |
4 | | - * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors |
| 4 | + * SPDX-FileCopyrightText: 2016-2025 Nextcloud GmbH and Nextcloud contributors |
5 | 5 | * SPDX-FileCopyrightText: 2016 ownCloud, Inc. |
6 | 6 | * SPDX-License-Identifier: AGPL-3.0-only |
7 | 7 | */ |
8 | | -// use OCP namespace for all classes that are considered public. |
9 | | -// This means that they should be used by apps instead of the internal Nextcloud classes |
10 | 8 |
|
11 | 9 | namespace OCP; |
12 | 10 |
|
13 | 11 | /** |
14 | | - * User session |
| 12 | + * Interface for managing and querying user session state. |
| 13 | + * |
| 14 | + * Provides methods for authenticating users, accessing the active user, |
| 15 | + * and handling login/logout functionality in a Nextcloud server session. |
15 | 16 | * @since 6.0.0 |
16 | 17 | */ |
17 | 18 | interface IUserSession { |
18 | 19 | /** |
19 | | - * Do a user login |
| 20 | + * Attempts to authenticate the given user and start a session. |
20 | 21 | * |
21 | | - * @param string $uid the username |
22 | | - * @param string $password the password |
23 | | - * @return bool true if successful |
| 22 | + * @param string $uid The user's unique identifier (username). |
| 23 | + * @param string $password The user's plain-text password. |
| 24 | + * @return bool True on successful login, false otherwise. |
24 | 25 | * @since 6.0.0 |
25 | 26 | */ |
26 | 27 | public function login($uid, $password); |
27 | 28 |
|
28 | 29 | /** |
29 | | - * Logs the user out including all the session data |
30 | | - * Logout, destroys session |
| 30 | + * Logs out the current user and terminates their session. |
| 31 | + * |
| 32 | + * Clears authentication tokens and user-related session data. |
31 | 33 | * |
32 | 34 | * @return void |
33 | 35 | * @since 6.0.0 |
34 | 36 | */ |
35 | 37 | public function logout(); |
36 | 38 |
|
37 | 39 | /** |
38 | | - * set the currently active user |
| 40 | + * Sets the current active user for this session. |
| 41 | + * |
| 42 | + * Pass null to clear the active user and log out any existing session. |
39 | 43 | * |
40 | | - * @param \OCP\IUser|null $user |
| 44 | + * @param \OCP\IUser|null $user The user to set as active, or null to unset. |
41 | 45 | * @since 8.0.0 |
42 | 46 | */ |
43 | 47 | public function setUser($user); |
44 | 48 |
|
45 | 49 | /** |
46 | | - * Temporarily set the currently active user without persisting in the session |
| 50 | + * Temporarily sets the active user for this session without persisting it in the session storage. |
| 51 | + * |
| 52 | + * Useful for request-scoped user overrides that do not affect the actual session state. |
47 | 53 | * |
48 | | - * @param IUser|null $user |
| 54 | + * @param \OCP\IUser|null $user The user to set as active, or null to clear. |
49 | 55 | * @since 29.0.0 |
50 | 56 | */ |
51 | 57 | public function setVolatileActiveUser(?IUser $user): void; |
52 | 58 |
|
53 | 59 | /** |
54 | | - * get the current active user |
| 60 | + * Returns the currently authenticated user for this session, or null if the session has no active user. |
55 | 61 | * |
56 | | - * @return \OCP\IUser|null Current user, otherwise null |
| 62 | + * @return \OCP\IUser|null The active user, or null if the session is anonymous, expired, or in incognito mode. |
57 | 63 | * @since 8.0.0 |
58 | 64 | */ |
59 | 65 | public function getUser(); |
60 | 66 |
|
61 | 67 | /** |
62 | | - * Checks whether the user is logged in |
| 68 | + * Checks whether a user is currently logged in for this session. |
63 | 69 | * |
64 | | - * @return bool if logged in |
| 70 | + * @return bool True if a user is authenticated and enabled, false otherwise. |
65 | 71 | * @since 8.0.0 |
66 | 72 | */ |
67 | 73 | public function isLoggedIn(); |
68 | 74 |
|
69 | 75 | /** |
70 | | - * get getImpersonatingUserID |
| 76 | + * Returns the user ID of the impersonator if another user is being impersonated. |
71 | 77 | * |
72 | | - * @return string|null |
| 78 | + * @return string|null The impersonating user's ID, or null if not impersonating. |
73 | 79 | * @since 18.0.0 |
74 | 80 | */ |
75 | 81 | public function getImpersonatingUserID(): ?string; |
76 | 82 |
|
77 | 83 | /** |
78 | | - * set setImpersonatingUserID |
| 84 | + * Sets or clears the impersonator's user ID in the current session. |
| 85 | + * |
| 86 | + * Note: This does not initiate impersonation, but only records the identity of the impersonator in the session. |
| 87 | + * |
| 88 | + * If $useCurrentUser is true (default), records the current user's ID as the impersonator. |
| 89 | + * If false, removes any impersonator information from the session. |
79 | 90 | * |
| 91 | + * @param bool $useCurrentUser Whether to assign the current user as the impersonator or to clear it. |
80 | 92 | * @since 18.0.0 |
81 | 93 | */ |
82 | 94 | public function setImpersonatingUserID(bool $useCurrentUser = true): void; |
|
0 commit comments