IUserSession.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. /**
  30. * Public interface of ownCloud for apps to use.
  31. * User session interface
  32. *
  33. */
  34. // use OCP namespace for all classes that are considered public.
  35. // This means that they should be used by apps instead of the internal ownCloud classes
  36. namespace OCP;
  37. /**
  38. * User session
  39. * @since 6.0.0
  40. */
  41. interface IUserSession {
  42. /**
  43. * Do a user login
  44. *
  45. * @param string $user the username
  46. * @param string $password the password
  47. * @return bool true if successful
  48. * @since 6.0.0
  49. */
  50. public function login($user, $password);
  51. /**
  52. * Logs the user out including all the session data
  53. * Logout, destroys session
  54. *
  55. * @return void
  56. * @since 6.0.0
  57. */
  58. public function logout();
  59. /**
  60. * set the currently active user
  61. *
  62. * @param \OCP\IUser|null $user
  63. * @since 8.0.0
  64. */
  65. public function setUser($user);
  66. /**
  67. * get the current active user
  68. *
  69. * @return \OCP\IUser|null Current user, otherwise null
  70. * @since 8.0.0
  71. */
  72. public function getUser();
  73. /**
  74. * Checks whether the user is logged in
  75. *
  76. * @return bool if logged in
  77. * @since 8.0.0
  78. */
  79. public function isLoggedIn();
  80. /**
  81. * get getImpersonatingUserID
  82. *
  83. * @return string|null
  84. * @since 18.0.0
  85. */
  86. public function getImpersonatingUserID(): ?string;
  87. /**
  88. * set setImpersonatingUserID
  89. *
  90. * @since 18.0.0
  91. */
  92. public function setImpersonatingUserID(bool $useCurrentUser = true): void;
  93. }