1
0
mirror of https://github.com/cydrobolt/polr.git synced 2024-09-19 23:21:47 +02:00

Ensure registration process is halted when errors occur

This commit is contained in:
Chaoyi Zha 2015-12-28 17:48:06 -05:00
parent 05c9ad4906
commit b662511aa9
4 changed files with 33 additions and 17 deletions

19
.env-temporary Normal file
View File

@ -0,0 +1,19 @@
APP_ENV=local
APP_DEBUG=true
APP_KEY=NOTREALLYRANDOMP
APP_LOCALE=en
APP_FALLBACK_LOCALE=en
POLR_SETUP_RAN=false
# DB_CONNECTION=mysql
# DB_HOST=localhost
# DB_PORT=3306
# DB_DATABASE=homestead
# DB_USERNAME=homestead
# DB_PASSWORD=secret
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=file

View File

@ -47,9 +47,7 @@ class UserController extends Controller {
public function performSignup(Request $request) {
if (env('POLR_ALLOW_ACCT_CREATION') == false) {
return view('error', [
'message' => 'Sorry, but registration is disabled.'
]);
return redirect('index')->with('error', 'Sorry, but registration is disabled.');
}
$username = $request->input('username');
@ -64,17 +62,13 @@ class UserController extends Controller {
if ($user_exists || $email_exists) {
// if user or email email
return view('signup', [
'error' => 'Sorry, your email or username already exists. Try again.'
]);
return redirect('signup')->with('error', 'Sorry, your email or username already exists. Try again.');
}
$email_valid = UserHelper::validateEmail($email);
if ($email_valid == false) {
return view('signup', [
'error' => 'Please use a valid email to sign up.'
]);
return redirect('signup')->with('error', 'Please use a valid email to sign up.');
}
$recovery_key = CryptoHelper::generateRandomHex(50);
@ -86,12 +80,11 @@ class UserController extends Controller {
$user->ip = $ip;
$acct_activation_needed = env('POLR_ACCT_ACTIVATION');
if ($acct_activation_needed == false) {
// if no activation is necessary
$user->active = 1;
$response = view('notice', [
'message' => 'Thanks for signing up! You may now log in.'
]);
$response = redirect('login')->with('success', 'Thanks for signing up! You may now log in.');
}
else {
// email activation is necessary
@ -100,9 +93,8 @@ class UserController extends Controller {
], function ($m) use ($user) {
$m->to($user->email, $user->username)->subject(env('APP_NAME') . ' account activation');
});
$response = view('notice', [
'message' => 'Thanks for signing up! Please confirm your email to activate your account.'
]);
$response = redirect('login')->with('success', 'Thanks for signing up! Please confirm your email to continue..');
}
$user->save();

3
public/css/setup.css Normal file
View File

@ -0,0 +1,3 @@
.setup-logo {
height: 70px;
}

View File

@ -5,11 +5,13 @@ Setup
@endsection
@section('css')
<link rel='stylesheet' href='/css/default-bootstrap.min.css' />
<link rel='stylesheet' href='/css/setup.css'>
<link rel='stylesheet' href='/css/default-bootstrap.min.css'>
@endsection
@section('content')
<img src='/img/logo.png' />
<img class='setup-logo' src='/img/logo.png' />
<h1>Setup</h1>