Add validation to signup and trans strings

This commit is contained in:
Joseph Cohen
2015-11-08 20:12:52 -06:00
parent a88140ed53
commit 0b12d4e0c3
5 changed files with 42 additions and 16 deletions

View File

@@ -11,6 +11,7 @@
namespace CachetHQ\Cachet\Http\Controllers;
use AltThree\Validator\ValidationException;
use CachetHQ\Cachet\Commands\Invite\ClaimInviteCommand;
use CachetHQ\Cachet\Commands\User\SignupUserCommand;
use CachetHQ\Cachet\Facades\Setting;
@@ -50,7 +51,9 @@ class SignupController extends Controller
return View::make('signup')
->withPageTitle(Setting::get('app_name'))
->withAboutApp(Markdown::convertToHtml(Setting::get('app_about')))
->withCode($invite->code);
->withCode($invite->code)
->withUsername(Binput::old('username'))
->withEmail(Binput::old('emai', $invite->email));
}
/**
@@ -72,16 +75,23 @@ class SignupController extends Controller
throw new BadRequestHttpException();
}
$this->dispatch(new SignupUserCommand(
Binput::get('username'),
Binput::get('password'),
Binput::get('email'),
2
));
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('<strong>%s</strong> %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.unsubscribed')));
->withSuccess(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.awesome'), trans('cachet.signup.unsubscribed')));
}
}