Skip to content

Commit 6ed3626

Browse files
committed
Merge pull request #65 from cachethq/elliotfehr-master
Fixed rebase issues
2 parents 7aec301 + 0fb39f3 commit 6ed3626

File tree

6 files changed

+37
-17
lines changed

6 files changed

+37
-17
lines changed

app/controllers/HomeController.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
<?php
22

33
class HomeController extends Controller {
4+
/**
5+
* @var Component $component
6+
*/
7+
protected $component;
8+
9+
public function __construct(Component $component) {
10+
$this->component = $component;
11+
}
12+
413
/**
514
* Returns the rendered Blade templates.
615
* @return \Illuminate\View\View
716
*/
817
public function showIndex() {
9-
return View::make('index', ['components' => Component::all()]);
18+
return View::make('index', ['components' => $this->component->all()]);
1019
}
1120
}

app/controllers/SetupController.php

+11-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
<?php
22

33
class SetupController extends Controller {
4+
public function __construct() {
5+
$this->beforeFilter('csrf', ['only' => ['postCachet']]);
6+
}
7+
48
/**
59
* Returns the setup page.
610
* @return \Illuminate\View\View
711
*/
8-
public function showSetup() {
12+
public function getIndex() {
913
return View::make('setup')->with([
1014
'pageTitle' => 'Setup'
1115
]);
@@ -15,26 +19,25 @@ public function showSetup() {
1519
* Handles the actual app setup.
1620
* @return \Illuminate\Http\RedirectResponse
1721
*/
18-
public function setupCachet() {
22+
public function postIndex() {
1923
$postData = Input::get();
2024
$v = Validator::make($postData, [
2125
'settings.app_name' => 'required',
22-
'settings.app_domain' => 'url|required',
26+
'settings.app_domain' => 'required',
2327
'settings.show_support' => 'boolean',
24-
'user.name' => 'alpha_dash|required',
28+
'user.username' => 'alpha_dash|required',
2529
'user.email' => 'email|required',
2630
'user.password' => 'required'
2731
]);
2832

2933
if ($v->passes()) {
3034
// Pull the user details out.
31-
$userDetails = array_get($postData, 'user');
32-
unset($postData['user']);
35+
$userDetails = array_pull($postData, 'user');
3336

3437
$user = new User;
35-
$user->username = $userDetails['name'];
38+
$user->username = $userDetails['username'];
3639
$user->email = $userDetails['email'];
37-
$user->password = Hash::make($userDetails['password']);
40+
$user->password = $userDetails['password'];
3841
$user->save();
3942

4043
Auth::login($user);

app/models/User.php

+11
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,15 @@ class User extends Eloquent implements UserInterface, RemindableInterface {
2323
*/
2424
protected $hidden = ['password', 'remember_token'];
2525

26+
/**
27+
* Hash any password being inserted by default
28+
*
29+
* @param string @password
30+
* @return void
31+
*/
32+
public function setPasswordAttribute($password) {
33+
$this->attributes['password'] = Hash::make($password);
34+
}
35+
36+
2637
}

app/routes/app.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
1010
});
1111

1212
Route::group(['before' => 'no_setup:app_name'], function() {
13-
Route::get('/setup', 'SetupController@showSetup');
14-
Route::group(['before' => 'csrf'], function() {
15-
Route::post('/setup', 'SetupController@setupCachet');
16-
});
13+
Route::controller('/setup', 'SetupController');
1714
});
1815

1916
Route::group(['before' => 'auth'], function() {

app/views/setup.blade.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141
<legend>Administrator Account</legend>
4242
<div class='form-group'>
4343
<label class='sr-only'>Username</label>
44-
<input type='text' name='user[name]' class='form-control' placeholder='Username' value='{{ Input::old('user.name', '') }}' required />
45-
@if($errors->has('user.name'))
46-
<span class='text-danger'>{{ $errors->first('user.name') }}</span>
44+
<input type='text' name='user[username]' class='form-control' placeholder='Username' value='{{ Input::old('user.username', '') }}' required />
45+
@if($errors->has('user.username'))
46+
<span class='text-danger'>{{ $errors->first('user.username') }}</span>
4747
@endif
4848
</div>
4949
<div class='form-group'>

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"scripts": {
4646
"post-install-cmd": [
4747
"php artisan optimize",
48-
"chmod -R 777 app/storage public",
48+
"chmod -R 755 app/storage",
4949
"php artisan migrate"
5050
],
5151
"post-update-cmd": [

0 commit comments

Comments
 (0)