Updated various classes and tests.

This commit is contained in:
James Cole
2014-07-02 23:31:59 +02:00
parent 063cf14531
commit 757e076a83
7 changed files with 190 additions and 94 deletions

View File

@@ -1,99 +1,99 @@
<?php
use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
//use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
class AccountController extends \BaseController {
public function __construct(ARI $accounts) {
$this->accounts = $accounts;
}
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
}
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
if($this->accounts->count() == 0) {
return View::make('accounts.create-first-time');
}
return View::make('accounts');
}
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$account = $this->accounts->store();
if($account === false) {
Session::flash('error','Could not create account with provided information');
return Redirect::route('accounts.create')->withInput()->withErrors($this->accounts->validator);
}
}
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
//
}
// public function __construct(ARI $accounts) {
// $this->accounts = $accounts;
// }
//
// /**
// * Display a listing of the resource.
// *
// * @return Response
// */
// public function index()
// {
//
// }
//
//
// /**
// * Show the form for creating a new resource.
// *
// * @return Response
// */
// public function create()
// {
// if($this->accounts->count() == 0) {
// return View::make('accounts.create-first-time');
// }
// return View::make('accounts');
// }
//
//
// /**
// * Store a newly created resource in storage.
// *
// * @return Response
// */
// public function store()
// {
// $account = $this->accounts->store();
// if($account === false) {
// Session::flash('error','Could not create account with provided information');
// return Redirect::route('accounts.create')->withInput()->withErrors($this->accounts->validator);
// }
// }
//
//
// /**
// * Display the specified resource.
// *
// * @param int $id
// * @return Response
// */
// public function show($id)
// {
// //
// }
//
//
// /**
// * Show the form for editing the specified resource.
// *
// * @param int $id
// * @return Response
// */
// public function edit($id)
// {
// //
// }
//
//
// /**
// * Update the specified resource in storage.
// *
// * @param int $id
// * @return Response
// */
// public function update($id)
// {
// //
// }
//
//
// /**
// * Remove the specified resource from storage.
// *
// * @param int $id
// * @return Response
// */
// public function destroy($id)
// {
// //
// }
}

View File

@@ -17,6 +17,7 @@ class ProfileController extends BaseController
{
// old, new1, new2
/** @noinspection PhpUndefinedFieldInspection */
if (!Hash::check(Input::get('old'), Auth::user()->password)) {
Session::flash('error', 'Invalid current password!');
return View::make('profile.change-password');
@@ -37,7 +38,9 @@ class ProfileController extends BaseController
// update the user with the new password.
$password = Hash::make(Input::get('new1'));
/** @noinspection PhpUndefinedFieldInspection */
Auth::user()->password = $password;
/** @noinspection PhpUndefinedMethodInspection */
Auth::user()->save();
Session::flash('success', 'Password changed!');
return Redirect::route('profile');

View File

@@ -26,6 +26,7 @@ class UserController extends BaseController
'password' => Input::get('password')
];
if (Auth::attempt($data, $rememberMe)) {
Session::flash('success', 'Logged in!');
return Redirect::route('index');
}
Session::flash('error', 'No good!');
@@ -35,7 +36,7 @@ class UserController extends BaseController
public function register()
{
if (Config::get('auth.allow_register') !== true) {
return App::abort(404);
App::abort(404);
}
return View::make('user.register');
}
@@ -43,7 +44,7 @@ class UserController extends BaseController
public function postRegister()
{
if (Config::get('auth.allow_register') !== true) {
return App::abort(404);
App::abort(404);
}
$user = $this->user->register(Input::all());
if ($user) {