| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- namespace app\api\controller;
- use app\common\model\Orders;
- use app\api\service\auth\ApiAuthService;
- use app\api\validate\User as UserValidate;
- use think\exception\ValidateException;
- use think\Cache;
- class User extends Base
- {
- protected $noNeedLogin = ['login'];
- public function userinfo(ApiAuthService $authService)
- {
-
- try{
-
-
- dump($this->userinfo);die;
- $user = $authService->userinfo();
- }catch (ValidateException $e) {
-
- return $this->error($e->getError());
- }catch (\Exception $e){
- return $this->error($e->getMessage());
- }
- return $this->success('ok', $user);
- }
- public function login(ApiAuthService $authService)
- {
- $data = $this->request->post();
- try{
-
- validate(UserValidate::class)->scene('login')->check($data);
- $user = $authService->login($data['username'],$data['password']);
- }catch (ValidateException $e) {
-
- return $this->error($e->getError());
- }catch (\Exception $e){
- return $this->error($e->getMessage());
- }
- return $this->success('ok', $user);
- }
- }
|