first(); if (!$invite || $invite->is_claimed) { throw new BadRequestHttpException(); } return View::make('signup') ->withCode($invite->code) ->withUsername(Binput::old('username')) ->withEmail(Binput::old('email', $invite->email)); } /** * Handle a signup request. * * @param string|null $code * * @return \Illuminate\View\View */ public function postSignup($code = null) { if ($code === null) { throw new NotFoundHttpException(); } $invite = Invite::where('code', '=', $code)->first(); if (!$invite || $invite->is_claimed) { throw new BadRequestHttpException(); } try { dispatch(new SignupUserCommand( Binput::get('username'), Binput::get('password'), Binput::get('email'), User::LEVEL_USER )); } catch (ValidationException $e) { return Redirect::route('signup.invite', ['code' => $invite->code]) ->withInput(Binput::except('password')) ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('cachet.signup.failure'))) ->withErrors($e->getMessageBag()); } dispatch(new ClaimInviteCommand($invite)); return Redirect::route('status-page') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('cachet.signup.success'))); } }