middleware('guest'); $this->userService = $userService; } /** * Create a new user instance after a valid registration. * * @param array $data * @return UserItem * @throws RpcException */ protected function create(array $data) { return $this->userService->create($data); } /** * @param RegisterCustomerRequest $request * @return \Illuminate\Http\RedirectResponse * @throws RpcException */ public function register(RegisterCustomerRequest $request) { $data = $request->except('_method', '_token'); if ($user = $this->create($data)) { $token = Auth::login($data); return redirect()->route('accounts')->cookie('jwt_token', $token); } else { throw new AuthenticationException('注册失败,请重试'); } } }