Create the admin user on setup.

This commit is contained in:
James Brooks 2014-11-24 15:54:56 +00:00
parent 27b3a128bd
commit 035f80ff50
3 changed files with 47 additions and 1 deletions

View File

@ -12,10 +12,25 @@
$v = Validator::make($postData, [
'app_name' => 'required',
'app_domain' => 'url|required',
'show_support' => 'boolean'
'show_support' => 'boolean',
'user.name'=> 'alpha_dash|required',
'user.email' => 'email|required',
'user.password' => 'required'
]);
if ($v->passes()) {
// Pull the user details out.
$userDetails = array_get($postData, 'user');
unset($postData['user']);
$user = new User;
$user->username = $userDetails['name'];
$user->email = $userDetails['email'];
$user->password = $userDetails['password'];
$user->save();
Auth::login($user);
// Create the settings, boi.
foreach ($postData as $settingName => $settingValue) {
$setting = new Setting;
@ -23,6 +38,7 @@
$setting->value = $settingValue;
$setting->save();
}
return Redirect::to('/');
} else {
// No good, let's try that again.

View File

@ -3,6 +3,10 @@
@section('content')
<div class='alert alert-{{ $systemStatus }}'>{{ $systemMessage }}</div>
@if(Auth::check())
<p>You're logged in. This will be a link to the Dashboard.</p>
@endif
<div class='page-header'>
<ul class='list-group components'>
@foreach(Component::get() as $component)

View File

@ -12,6 +12,7 @@
<div class='panel-heading'>Service Details</div>
<div class='panel-body'>
<form name='SetupForm' class='form-vertical' role='form' method="POST">
<h3>Status Page Details</h3>
<div class='form-group'>
<label class='sr-only'>Site Name</label>
<input type='text' name='app_name' class='form-control' placeholder='Site Name' required />
@ -32,6 +33,31 @@
</label>
Show support for Cachet?
</div>
<h3>Administrator Account</h3>
<div class='form-group'>
<label class='sr-only'>Username</label>
<input type='text' name='user[name]' class='form-control' placeholder='Username' required />
@if($errors->has('user.name'))
<span class='text-danger'>{{ $errors->first('user.name') }}</span>
@endif
</div>
<div class='form-group'>
<label class='sr-only'>Email</label>
<input type='email' name='user[email]' class='form-control' placeholder='Email' required />
@if($errors->has('user.email'))
<span class='text-danger'>{{ $errors->first('user.email') }}</span>
@endif
</div>
<div class='form-group'>
<label class='sr-only'>Password</label>
<input type='password' name='user[password]' class='form-control' placeholder='Password' required />
@if($errors->has('user.password'))
<span class='text-danger'>{{ $errors->first('user.password') }}</span>
@endif
</div>
<hr />
<div class='form-group'>
<button type='submit' class='btn btn-default'>Setup!</button>
</div>