1
0

IUser.php 6.5 KB

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