您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

LuticateUsersController.php 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <?php
  2. namespace Luticate\Auth\Controller;
  3. use Luticate\Utils\LuController;
  4. use Luticate\Auth\Business\LuticateUsersBusiness;
  5. use Luticate\Auth\DBO\LuticateUsersDbo;
  6. class LuticateUsersController extends LuController {
  7. protected function getBusiness()
  8. {
  9. return new LuticateUsersBusiness();
  10. }
  11. /**
  12. * Login the user
  13. * @param $username string The user username
  14. * @param $password string The user password
  15. * @return LuticateUsersDbo
  16. */
  17. public function login($username, $password)
  18. {
  19. return LuticateUsersBusiness::login($username, $password);
  20. }
  21. /**
  22. * Logout the logged user
  23. * @param $_user LuticateUsersDbo The logged user
  24. * @return bool
  25. */
  26. public function logout($_user)
  27. {
  28. return LuticateUsersBusiness::logout($_user);
  29. }
  30. /**
  31. * Get a user by its id
  32. * @param $user_id int The user id
  33. * @return \Luticate\Utils\LuDbo
  34. */
  35. public function getLightById($user_id)
  36. {
  37. return LuticateUsersBusiness::getLightById($user_id);
  38. }
  39. /**
  40. * Get all users
  41. * @param int $page The page number, 0 based
  42. * @param int $perPage The number of items per page
  43. * @return array
  44. */
  45. public function getAllLight($page = 0, $perPage = PHP_INT_MAX)
  46. {
  47. return LuticateUsersBusiness::getAllLight($page, $perPage);
  48. }
  49. /**
  50. * Add a user
  51. * @param $username string The new user username
  52. * @param $email string The new user email
  53. * @param $firstname string The user firstname
  54. * @param $lastname string The user lastname
  55. * @param $password string The new user plain text password
  56. * @return int
  57. */
  58. public function add($username, $email, $firstname, $lastname, $password)
  59. {
  60. return LuticateUsersBusiness::add($username, $email, $firstname, $lastname, $password);
  61. }
  62. /**
  63. * Delete a user by its id
  64. * @param $user_id int The user id
  65. * @return bool
  66. */
  67. public function del($user_id)
  68. {
  69. return LuticateUsersBusiness::deleteById($user_id);
  70. }
  71. /**
  72. * Edit the user details
  73. * @param $email string The new user amil
  74. * @param $user_id int The user id
  75. * @param $firstname string The user firstname
  76. * @param $lastname string The user lastname
  77. * @return bool
  78. */
  79. public function edit($email, $firstname, $lastname, $user_id)
  80. {
  81. return LuticateUsersBusiness::edit($user_id, $firstname, $lastname, $email);
  82. }
  83. /**
  84. * Edit the logged user email
  85. * @param $email string The new user email
  86. * @param $firstname string The user firstname
  87. * @param $lastname string The user lastname
  88. * @param $_user LuticateUsersDbo The logged user
  89. * @return bool
  90. */
  91. public function editMe($email, $firstname, $lastname, $_user)
  92. {
  93. return LuticateUsersBusiness::edit($_user->getId(), $firstname, $lastname, $email);
  94. }
  95. /**
  96. * Edit the password for a user
  97. * @param $password string The new plain text password
  98. * @param $user_id int The user id
  99. * @return bool
  100. */
  101. public function setPassword($password, $user_id)
  102. {
  103. return LuticateUsersBusiness::setPassword($user_id, $password);
  104. }
  105. /**
  106. * Edit the password for the logged user
  107. * @param $password string The new plain text password
  108. * @param $oldPassword string The old plain text password
  109. * @param $_user LuticateUsersDbo The logged user
  110. * @return bool
  111. */
  112. public function setPasswordMe($password, $oldPassword, $_user)
  113. {
  114. return LuticateUsersBusiness::setPasswordMe($password, $oldPassword, $_user);
  115. }
  116. }