AuthController.php 906 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace App\Modules\Admin\Controllers\Admin;
  3. use App\Base\BaseController;
  4. use App\Modules\Admin\Services\AuthService;
  5. class AuthController extends BaseController
  6. {
  7. protected $authService;
  8. public function __construct(AuthService $authService)
  9. {
  10. $this->authService = $authService;
  11. }
  12. public function login()
  13. {
  14. $data = $this->valid([
  15. "username" => "required",
  16. "password" => "required",
  17. "fix" => "",
  18. ]);
  19. return $this->ok($this->authService->login($data));
  20. }
  21. public function profile()
  22. {
  23. return $this->ok($this->authService->profile());
  24. }
  25. public function changePassword()
  26. {
  27. $data = $this->valid([
  28. "old_password" => "required",
  29. "password" => "required",
  30. ]);
  31. return $this->ok($this->authService->changePassword($data));
  32. }
  33. }