first(); if (!$invite || $invite->claimed()) { throw new BadRequestHttpException(); } return View::make('signup') ->withPageTitle(Setting::get('app_name')) ->withAboutApp(Markdown::convertToHtml(Setting::get('app_about'))) ->withCode($invite->code) ->withUsername(Binput::old('username')) ->withEmail(Binput::old('emai', $invite->email)); } /** * Handle the unsubscribe. * * @param string|null $code * * @return \Illuminate\View\View */ public function postSignup($code = null) { if (is_null($code)) { throw new NotFoundHttpException(); } $invite = Invite::where('code', '=', $code)->first(); if (!$invite || $invite->claimed()) { throw new BadRequestHttpException(); } try { $this->dispatch(new SignupUserCommand( Binput::get('username'), Binput::get('password'), Binput::get('email'), 2 )); } 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()); } $this->dispatch(new ClaimInviteCommand($invite)); return Redirect::route('status-page') ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('cachet.signup.unsubscribed'))); } }