IUserSession.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. // use OCP namespace for all classes that are considered public.
  8. // This means that they should be used by apps instead of the internal Nextcloud classes
  9. namespace OCP;
  10. /**
  11. * User session
  12. * @since 6.0.0
  13. */
  14. interface IUserSession {
  15. /**
  16. * Do a user login
  17. *
  18. * @param string $uid the username
  19. * @param string $password the password
  20. * @return bool true if successful
  21. * @since 6.0.0
  22. */
  23. public function login($uid, $password);
  24. /**
  25. * Logs the user out including all the session data
  26. * Logout, destroys session
  27. *
  28. * @return void
  29. * @since 6.0.0
  30. */
  31. public function logout();
  32. /**
  33. * set the currently active user
  34. *
  35. * @param \OCP\IUser|null $user
  36. * @since 8.0.0
  37. */
  38. public function setUser($user);
  39. /**
  40. * Temporarily set the currently active user without persisting in the session
  41. *
  42. * @param IUser|null $user
  43. * @since 29.0.0
  44. */
  45. public function setVolatileActiveUser(?IUser $user): void;
  46. /**
  47. * get the current active user
  48. *
  49. * @return \OCP\IUser|null Current user, otherwise null
  50. * @since 8.0.0
  51. */
  52. public function getUser();
  53. /**
  54. * Checks whether the user is logged in
  55. *
  56. * @return bool if logged in
  57. * @since 8.0.0
  58. */
  59. public function isLoggedIn();
  60. /**
  61. * get getImpersonatingUserID
  62. *
  63. * @return string|null
  64. * @since 18.0.0
  65. */
  66. public function getImpersonatingUserID(): ?string;
  67. /**
  68. * set setImpersonatingUserID
  69. *
  70. * @since 18.0.0
  71. */
  72. public function setImpersonatingUserID(bool $useCurrentUser = true): void;
  73. }