authorize('admin', $this->invitor); $invitees = $this->invitationService->invite( $request->emails, $request->get('is_admin') ?: false, $this->invitor ); return UserProspectResource::collection($invitees); } public function get(GetUserInvitationRequest $request) { try { return UserProspectResource::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.'); } } }