IUserSession.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. * get the current active user
  63. *
  64. * @return \OCP\IUser|null Current user, otherwise null
  65. * @since 8.0.0
  66. */
  67. public function getUser();
  68. /**
  69. * Checks whether the user is logged in
  70. *
  71. * @return bool if logged in
  72. * @since 8.0.0
  73. */
  74. public function isLoggedIn();
  75. /**
  76. * get getImpersonatingUserID
  77. *
  78. * @return string|null
  79. * @since 18.0.0
  80. */
  81. public function getImpersonatingUserID(): ?string;
  82. /**
  83. * set setImpersonatingUserID
  84. *
  85. * @since 18.0.0
  86. */
  87. public function setImpersonatingUserID(bool $useCurrentUser = true): void;
  88. }