IUser.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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. namespace OCP;
  8. use InvalidArgumentException;
  9. /**
  10. * Interface IUser
  11. *
  12. * @since 8.0.0
  13. */
  14. interface IUser {
  15. /**
  16. * get the user id
  17. *
  18. * @return string
  19. * @since 8.0.0
  20. */
  21. public function getUID();
  22. /**
  23. * get the display name for the user, if no specific display name is set it will fallback to the user id
  24. *
  25. * @return string
  26. * @since 8.0.0
  27. */
  28. public function getDisplayName();
  29. /**
  30. * set the display name for the user
  31. *
  32. * @param string $displayName
  33. * @return bool
  34. * @since 8.0.0
  35. *
  36. * @since 25.0.0 Throw InvalidArgumentException
  37. * @throws \InvalidArgumentException
  38. */
  39. public function setDisplayName($displayName);
  40. /**
  41. * returns the timestamp of the user's last login or 0 if the user did never
  42. * login
  43. *
  44. * @return int
  45. * @since 8.0.0
  46. */
  47. public function getLastLogin();
  48. /**
  49. * updates the timestamp of the most recent login of this user
  50. * @since 8.0.0
  51. */
  52. public function updateLastLoginTimestamp();
  53. /**
  54. * Delete the user
  55. *
  56. * @return bool
  57. * @since 8.0.0
  58. */
  59. public function delete();
  60. /**
  61. * Set the password of the user
  62. *
  63. * @param string $password
  64. * @param string $recoveryPassword for the encryption app to reset encryption keys
  65. * @return bool
  66. * @since 8.0.0
  67. */
  68. public function setPassword($password, $recoveryPassword = null);
  69. /**
  70. * Get the password hash of the user
  71. *
  72. * @return ?string the password hash hashed by `\OCP\Security\IHasher::hash()`
  73. * @since 30.0.0
  74. */
  75. public function getPasswordHash(): ?string;
  76. /**
  77. * Set the password hash of the user
  78. *
  79. * @param string $passwordHash the password hash hashed by `\OCP\Security\IHasher::hash()`
  80. * @throws InvalidArgumentException when `$passwordHash` is not a valid hash
  81. * @since 30.0.0
  82. */
  83. public function setPasswordHash(string $passwordHash): bool;
  84. /**
  85. * get the users home folder to mount
  86. *
  87. * @return string
  88. * @since 8.0.0
  89. */
  90. public function getHome();
  91. /**
  92. * Get the name of the backend class the user is connected with
  93. *
  94. * @return string
  95. * @since 8.0.0
  96. */
  97. public function getBackendClassName();
  98. /**
  99. * Get the backend for the current user object
  100. * @return ?UserInterface
  101. * @since 15.0.0
  102. */
  103. public function getBackend();
  104. /**
  105. * check if the backend allows the user to change their avatar on Personal page
  106. *
  107. * @return bool
  108. * @since 8.0.0
  109. */
  110. public function canChangeAvatar();
  111. /**
  112. * check if the backend supports changing passwords
  113. *
  114. * @return bool
  115. * @since 8.0.0
  116. */
  117. public function canChangePassword();
  118. /**
  119. * check if the backend supports changing display names
  120. *
  121. * @return bool
  122. * @since 8.0.0
  123. */
  124. public function canChangeDisplayName();
  125. /**
  126. * check if the user is enabled
  127. *
  128. * @return bool
  129. * @since 8.0.0
  130. */
  131. public function isEnabled();
  132. /**
  133. * set the enabled status for the user
  134. *
  135. * @param bool $enabled
  136. * @since 8.0.0
  137. */
  138. public function setEnabled(bool $enabled = true);
  139. /**
  140. * get the user's email address
  141. *
  142. * @return string|null
  143. * @since 9.0.0
  144. */
  145. public function getEMailAddress();
  146. /**
  147. * get the user's system email address
  148. *
  149. * The system mail address may be read only and may be set from different
  150. * sources like LDAP, SAML or simply the admin.
  151. *
  152. * Use this getter only when the system address is needed. For picking the
  153. * proper address to e.g. send a mail to, use getEMailAddress().
  154. *
  155. * @return string|null
  156. * @since 23.0.0
  157. */
  158. public function getSystemEMailAddress(): ?string;
  159. /**
  160. * get the user's preferred email address
  161. *
  162. * The primary mail address may be set be the user to specify a different
  163. * email address where mails by Nextcloud are sent to. It is not necessarily
  164. * set.
  165. *
  166. * Use this getter only when the primary address is needed. For picking the
  167. * proper address to e.g. send a mail to, use getEMailAddress().
  168. *
  169. * @return string|null
  170. * @since 23.0.0
  171. */
  172. public function getPrimaryEMailAddress(): ?string;
  173. /**
  174. * get the avatar image if it exists
  175. *
  176. * @param int $size
  177. * @return IImage|null
  178. * @since 9.0.0
  179. */
  180. public function getAvatarImage($size);
  181. /**
  182. * get the federation cloud id
  183. *
  184. * @return string
  185. * @since 9.0.0
  186. */
  187. public function getCloudId();
  188. /**
  189. * set the email address of the user
  190. *
  191. * It is an alias to setSystemEMailAddress()
  192. *
  193. * @param string|null $mailAddress
  194. * @return void
  195. * @since 9.0.0
  196. * @deprecated 23.0.0 use setSystemEMailAddress() or setPrimaryEMailAddress()
  197. */
  198. public function setEMailAddress($mailAddress);
  199. /**
  200. * Set the system email address of the user
  201. *
  202. * This is supposed to be used when the email is set from different sources
  203. * (i.e. other user backends, admin).
  204. *
  205. * @since 23.0.0
  206. */
  207. public function setSystemEMailAddress(string $mailAddress): void;
  208. /**
  209. * Set the primary email address of the user.
  210. *
  211. * This method should be typically called when the user is changing their
  212. * own primary address and is not allowed to change their system email.
  213. *
  214. * The mail address provided here must be already registered as an
  215. * additional mail in the user account and also be verified locally. Also
  216. * an empty string is allowed to delete this preference.
  217. *
  218. * @throws InvalidArgumentException when the provided email address does not
  219. * satisfy constraints.
  220. *
  221. * @since 23.0.0
  222. */
  223. public function setPrimaryEMailAddress(string $mailAddress): void;
  224. /**
  225. * get the users' quota in human readable form. If a specific quota is not
  226. * set for the user, the default value is returned. If a default setting
  227. * was not set otherwise, it is return as 'none', i.e. quota is not limited.
  228. *
  229. * @return string
  230. * @since 9.0.0
  231. */
  232. public function getQuota();
  233. /**
  234. * set the users' quota
  235. *
  236. * @param string $quota
  237. * @return void
  238. * @since 9.0.0
  239. */
  240. public function setQuota($quota);
  241. /**
  242. * Get the user's manager UIDs
  243. *
  244. * @since 27.0.0
  245. * @return string[]
  246. */
  247. public function getManagerUids(): array;
  248. /**
  249. * Set the user's manager UIDs
  250. *
  251. * @param string[] $uids UIDs of all managers
  252. * @return void
  253. * @since 27.0.0
  254. */
  255. public function setManagerUids(array $uids): void;
  256. }