Cleaned up some views and controllers; basic auto + password change has been fixed.

This commit is contained in:
James Cole
2014-07-02 21:58:40 +02:00
parent 43204a3a95
commit 3a7c543afb
5 changed files with 51 additions and 39 deletions

View File

@@ -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');
}
}

View File

@@ -0,0 +1,46 @@
<?php
class ProfileController extends BaseController
{
public function index()
{
return View::make('profile.index');
}
public function changePassword()
{
return View::make('profile.change-password');
}
public function postChangePassword()
{
// old, new1, new2
if (!Hash::check(Input::get('old'), Auth::user()->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');
}
}