From 3a7c543afb092e564cc6b6de207dc0e21c8a6631 Mon Sep 17 00:00:00 2001 From: James Cole Date: Wed, 2 Jul 2014 21:58:40 +0200 Subject: [PATCH] Cleaned up some views and controllers; basic auto + password change has been fixed. --- app/controllers/HomeController.php | 10 ------ app/controllers/ProfileController.php | 46 +++++++++++++++++++++++++++ app/routes.php | 14 +++----- app/tests/ExampleTest.php | 2 +- app/views/index.blade.php | 18 ----------- 5 files changed, 51 insertions(+), 39 deletions(-) create mode 100644 app/controllers/ProfileController.php diff --git a/app/controllers/HomeController.php b/app/controllers/HomeController.php index 5619bfd06e..8ec3753f84 100644 --- a/app/controllers/HomeController.php +++ b/app/controllers/HomeController.php @@ -10,16 +10,6 @@ class HomeController extends BaseController { public function index() { - - $count = $this->accounts->count(); - if($count == 0) { - return Redirect::route('start'); - } return View::make('index'); } - - public function start() { - return View::make('start'); - } - } diff --git a/app/controllers/ProfileController.php b/app/controllers/ProfileController.php new file mode 100644 index 0000000000..280c4ec83e --- /dev/null +++ b/app/controllers/ProfileController.php @@ -0,0 +1,46 @@ +password)) { + Session::flash('error', 'Invalid current password!'); + return View::make('profile.change-password'); + } + if (strlen(Input::get('new1')) == 0 || strlen(Input::get('new2')) == 0) { + Session::flash('error', 'Do fill in a password!'); + return View::make('profile.change-password'); + } + if (Input::get('new1') == Input::get('old')) { + Session::flash('error', 'The idea is to change your password.'); + return View::make('profile.change-password'); + } + + if (Input::get('new1') !== Input::get('new2')) { + Session::flash('error', 'New passwords do not match!'); + return View::make('profile.change-password'); + } + + // update the user with the new password. + $password = Hash::make(Input::get('new1')); + Auth::user()->password = $password; + Auth::user()->save(); + Session::flash('success', 'Password changed!'); + return Redirect::route('profile'); + } + +} \ No newline at end of file diff --git a/app/routes.php b/app/routes.php index 0f748840c1..b6a0142c8a 100644 --- a/app/routes.php +++ b/app/routes.php @@ -2,13 +2,6 @@ // basic home views: Route::get('/', ['uses' => 'HomeController@index','as' => 'index','before' => 'auth']); -Route::get('/start', ['uses' => 'HomeController@start','as' => 'start','before' => 'auth']); - -// migration controller: -//Route::get('/migrate/index', ['uses' => 'MigrationController@index','as' => 'migrate.index', 'before' => 'auth']); -//Route::get('/migrate/select-user', ['uses' => 'MigrationController@selectUser','as' => 'migrate.select-user', 'before' => 'auth']); -//Route::post('/migrate/select-user', ['uses' => 'MigrationController@postSelectUser','before' => 'csrf|auth']); -//Route::get('/migrate/migrate/{userID}', ['uses' => 'MigrationController@migrate','as' => 'migrate.migrate', 'before' => 'auth']); // login, register, logout: Route::get('/login',['uses' => 'UserController@login','as' => 'login','before' => 'guest']); @@ -21,6 +14,7 @@ Route::post('/login',['uses' => 'UserController@postLogin','before' => 'csrf|gue Route::post('/register',['uses' => 'UserController@postRegister','before' => 'csrf|guest']); Route::post('/remindme',['uses' => 'UserController@postRemindme','before' => 'csrf|guest']); -// accountcontroller -Route::get('/accounts/create',['uses' => 'AccountController@create','as' => 'accounts.create','before' => 'auth']); -Route::post('/accounts/store',['uses' => 'AccountController@store','as' => 'accounts.store','before' => 'csrf|auth']); \ No newline at end of file +// profile (after login / logout) +Route::get('/profile',['uses' => 'ProfileController@index','as' => 'profile','before' => 'auth']); +Route::get('/profile/change-password',['uses' => 'ProfileController@changePassword','as' => 'change-password','before' => 'auth']); +Route::post('/profile/change-password',['uses' => 'ProfileController@postChangePassword','before' => 'csrf|auth']); \ No newline at end of file diff --git a/app/tests/ExampleTest.php b/app/tests/ExampleTest.php index 62387de14a..bad42bad5d 100644 --- a/app/tests/ExampleTest.php +++ b/app/tests/ExampleTest.php @@ -9,7 +9,7 @@ class ExampleTest extends TestCase { */ public function testBasicExample() { - $crawler = $this->client->request('GET', '/'); + $crawler = $this->client->request('GET', '/login'); $this->assertTrue($this->client->getResponse()->isOk()); } diff --git a/app/views/index.blade.php b/app/views/index.blade.php index aeadee8382..c45c7d3730 100644 --- a/app/views/index.blade.php +++ b/app/views/index.blade.php @@ -7,24 +7,6 @@ -
-
-

Accounts

- -

[settings]

-
-
- -
-
-

Expenses

-
-
-

Budgets

-
-
@stop @section('scripts') - - @stop \ No newline at end of file