AuthController.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace App\Http\Controllers\Manage\Manage;
  3. use App\Http\Controllers\Controller;
  4. use App\Modules\Manage\Services\ManageService;
  5. use Illuminate\Http\Request;
  6. use Cache;
  7. class AuthController extends Controller
  8. {
  9. /**
  10. * @apiDefine Manage 管理
  11. */
  12. /**
  13. * @apiVersion 1.0.0
  14. * @apiDescription 管理后台登陆
  15. * @api {POST} auth/login 管理后台登陆
  16. * @apiGroup Manage
  17. * @apiName login
  18. * @apiParam {String} accout 账号.
  19. * @apiParam {String} password 密码.
  20. * @apiSuccessExample {json} Success-Response:
  21. *
  22. * {
  23. * "code": 0,
  24. * "msg": "",
  25. * "data": {}
  26. * }
  27. */
  28. function login(Request $request)
  29. {
  30. $account = $request->has('account') ? trim($request->input('account')) : '';
  31. $password = $request->has('password') ? trim($request->input('password')) : '';
  32. // var_dump('$password:'.$password.' $account:'.$account);die();
  33. if(!$account || !$password) return response()->error('PARAM_ERROR');
  34. $manage = ManageService::getByAccount($account);
  35. // var_dump($manage);
  36. if($manage && $manage->password == md5($password."^-^zhuishuyun^_^"))
  37. {
  38. if($manage->is_enabled == 0) return response()->error('MANAGE_NOT_ENABLED');
  39. $request->session()->put('manage_auth', $manage->id);
  40. $request->session()->put('manage_user', serialize($manage));
  41. $options = [];
  42. $options =[
  43. 'role'=>$manage->role
  44. ];
  45. // $options = json_encode($options);
  46. return response()->success(compact('options'));
  47. }
  48. return response()->error('LOGIN_VERIFY_ERROR');
  49. }
  50. }