Example #1
0
 /**
  * 添加用户
  *
  * @param CreateRequest $request
  * @return mixed
  */
 public function postCreate(Request $request)
 {
     $user = $this->userRepository->store($request->all());
     if ($user) {
         //给注册用户发邮件
         //event(new UserCreate($user));
         return responseSuccess($user);
     }
     return responseWrong();
 }
Example #2
0
 /**
  * @api {post} /auth/login 登录
  */
 public function login(Request $request)
 {
     // grab credentials from the request
     $credentials = $request->only('username', 'password');
     try {
         // attempt to verify the credentials and create a token for the user
         if (!($token = JWTAuth::attempt($credentials))) {
             return responseWrong('账号或密码错误');
         }
     } catch (JWTException $e) {
         // something went wrong whilst attempting to encode the token
         return responseWrong('token创建失败');
     }
     // all good so return the token
     return response()->json(compact('token'));
 }