Open register page after a clean installation (#954)

* Redirect to /register if there is no account
* Remove default creation for admin@admin.com
This commit is contained in:
Alexis Saettler
2018-03-13 23:28:42 +01:00
committed by GitHub
parent 9a5a35332e
commit 67aa882eee
16 changed files with 83 additions and 48 deletions
@@ -49,11 +49,12 @@ class RegisterController extends Controller
*/
public function showRegistrationForm()
{
if (config('monica.disable_signup') == 'true') {
$first = ! Account::hasAny();
if (config('monica.disable_signup') == 'true' && ! $first) {
abort(403, trans('auth.signup_disabled'));
}
return view('auth.register');
return view('auth.register', ['first' => $first]);
}
/**
@@ -80,11 +81,14 @@ class RegisterController extends Controller
*/
protected function create(array $data)
{
$first = ! Account::hasAny();
$account = Account::createDefault($data['first_name'], $data['last_name'], $data['email'], $data['password']);
$user = $account->users()->first();
// send me an alert
dispatch(new SendNewUserAlert($user));
if (! $first) {
// send me an alert
dispatch(new SendNewUserAlert($user));
}
return $user;
}