2014-07-02 14:58:40 -05:00
|
|
|
<?php
|
|
|
|
|
2014-07-03 02:16:17 -05:00
|
|
|
use Firefly\Storage\User\UserRepositoryInterface as URI;
|
|
|
|
|
2014-07-02 14:58:40 -05:00
|
|
|
class ProfileController extends BaseController
|
|
|
|
{
|
|
|
|
|
2014-07-03 02:16:17 -05:00
|
|
|
public function __construct(URI $user) {
|
|
|
|
$this->user = $user;
|
2014-07-06 08:18:11 -05:00
|
|
|
View::share('menu', 'home');
|
2014-07-03 02:16:17 -05:00
|
|
|
}
|
|
|
|
|
2014-07-02 14:58:40 -05:00
|
|
|
public function index()
|
|
|
|
{
|
|
|
|
return View::make('profile.index');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function changePassword()
|
|
|
|
{
|
|
|
|
return View::make('profile.change-password');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function postChangePassword()
|
|
|
|
{
|
|
|
|
|
|
|
|
// old, new1, new2
|
2014-07-02 16:31:59 -05:00
|
|
|
/** @noinspection PhpUndefinedFieldInspection */
|
2014-07-02 14:58:40 -05:00
|
|
|
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.
|
2014-07-03 02:16:17 -05:00
|
|
|
$this->user->updatePassword(Auth::user(),Input::get('new1'));
|
|
|
|
|
2014-07-02 14:58:40 -05:00
|
|
|
Session::flash('success', 'Password changed!');
|
|
|
|
return Redirect::route('profile');
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|