authorize('admin', $this->invitor); $invitees = $this->invitationService->invite( $request->emails, $request->get('is_admin') ?: false, $this->invitor ); return UserResource::collection($invitees); } public function get(GetUserInvitationRequest $request) { try { return UserResource::make($this->invitationService->getUserProspectByToken($request->token)); } catch (InvitationNotFoundException) { abort(Response::HTTP_NOT_FOUND, 'The invitation token is invalid.'); } } public function accept(AcceptUserInvitationRequest $request) { try { $user = $this->invitationService->accept($request->token, $request->name, $request->password); return response()->json($this->auth->login($user->email, $request->password)->toArray()); } catch (InvitationNotFoundException) { abort(Response::HTTP_NOT_FOUND, 'The invitation token is invalid.'); } } public function revoke(RevokeUserInvitationRequest $request) { $this->authorize('admin', $this->invitor); try { $this->invitationService->revokeByEmail($request->email); return response()->noContent(); } catch (InvitationNotFoundException) { abort(Response::HTTP_NOT_FOUND, 'The invitation token is invalid.'); } } }