1
0

IUserSession.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Bart Visscher <bartv@thisnet.nl>
  6. * @author Bernhard Posselt <dev@bernhard-posselt.com>
  7. * @author Greta Doci <gretadoci@gmail.com>
  8. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  9. * @author Lukas Reschke <lukas@statuscode.ch>
  10. * @author Morris Jobke <hey@morrisjobke.de>
  11. * @author Robin Appelman <robin@icewind.nl>
  12. * @author Roeland Jago Douma <roeland@famdouma.nl>
  13. *
  14. * @license AGPL-3.0
  15. *
  16. * This code is free software: you can redistribute it and/or modify
  17. * it under the terms of the GNU Affero General Public License, version 3,
  18. * as published by the Free Software Foundation.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU Affero General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU Affero General Public License, version 3,
  26. * along with this program. If not, see <http://www.gnu.org/licenses/>
  27. *
  28. */
  29. // use OCP namespace for all classes that are considered public.
  30. // This means that they should be used by apps instead of the internal ownCloud classes
  31. namespace OCP;
  32. /**
  33. * User session
  34. * @since 6.0.0
  35. */
  36. interface IUserSession {
  37. /**
  38. * Do a user login
  39. *
  40. * @param string $uid the username
  41. * @param string $password the password
  42. * @return bool true if successful
  43. * @since 6.0.0
  44. */
  45. public function login($uid, $password);
  46. /**
  47. * Logs the user out including all the session data
  48. * Logout, destroys session
  49. *
  50. * @return void
  51. * @since 6.0.0
  52. */
  53. public function logout();
  54. /**
  55. * set the currently active user
  56. *
  57. * @param \OCP\IUser|null $user
  58. * @since 8.0.0
  59. */
  60. public function setUser($user);
  61. /**
  62. * Temporarily set the currently active user without persisting in the session
  63. *
  64. * @param IUser|null $user
  65. * @since 29.0.0
  66. */
  67. public function setVolatileActiveUser(?IUser $user): void;
  68. /**
  69. * get the current active user
  70. *
  71. * @return \OCP\IUser|null Current user, otherwise null
  72. * @since 8.0.0
  73. */
  74. public function getUser();
  75. /**
  76. * Checks whether the user is logged in
  77. *
  78. * @return bool if logged in
  79. * @since 8.0.0
  80. */
  81. public function isLoggedIn();
  82. /**
  83. * get getImpersonatingUserID
  84. *
  85. * @return string|null
  86. * @since 18.0.0
  87. */
  88. public function getImpersonatingUserID(): ?string;
  89. /**
  90. * set setImpersonatingUserID
  91. *
  92. * @since 18.0.0
  93. */
  94. public function setImpersonatingUserID(bool $useCurrentUser = true): void;
  95. }