Added some new code to implement a permission scheme.

This commit is contained in:
James Cole 2015-05-28 06:43:07 +02:00
parent ad0319c188
commit 67d9154563
16 changed files with 485 additions and 154 deletions

View File

@ -17,4 +17,5 @@ EMAIL_USERNAME=
EMAIL_PASSWORD=
ANALYTICS_ID=
EMAIL_PRETEND=false
RUNCLEANUP=true
RUNCLEANUP=true
SITE_OWNER=mail@example.com

View File

@ -2,6 +2,7 @@
use App;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Role;
use FireflyIII\User;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Contracts\Auth\Registrar;
@ -104,6 +105,13 @@ class AuthController extends Controller
Session::flash('gaEventCategory', 'user');
Session::flash('gaEventAction', 'new-registration');
// first user ever?
if (User::count() == 1) {
$admin = Role::where('name', 'owner')->first();
$this->auth->user()->attachRole($admin);
// $this->auth->user()->roles()->save($admin);
}
return redirect($this->redirectPath());
}

View File

@ -1,5 +1,6 @@
<?php namespace FireflyIII\Http\Controllers;
use Auth;
use Cache;
use FireflyIII\Http\Requests\CurrencyFormRequest;
use FireflyIII\Models\TransactionCurrency;
@ -107,8 +108,9 @@ class CurrencyController extends Controller
}
Session::flash('success', 'Currency "' . e($currency->name) . '" deleted');
$currency->delete();
if (Auth::user()->hasRole('owner')) {
$currency->delete();
}
return Redirect::to(Session::get('currency.delete.url'));
}
@ -146,6 +148,12 @@ class CurrencyController extends Controller
$currencies = $repository->get();
$defaultCurrency = $repository->getCurrencyByPreference(Preferences::get('currencyPreference', 'EUR'));
if (!Auth::user()->hasRole('owner')) {
Session::flash('warning', 'Please ask ' . env('SITE_OWNER') . ' to add, remove or edit currencies.');
}
return view('currency.index', compact('currencies', 'defaultCurrency'));
}
@ -158,11 +166,11 @@ class CurrencyController extends Controller
*/
public function store(CurrencyFormRequest $request, CurrencyRepositoryInterface $repository)
{
$data = $request->getCurrencyData();
$currency = $repository->store($data);
Session::flash('success', 'Currency "' . $currency->name . '" created');
$data = $request->getCurrencyData();
if (Auth::user()->hasRole('owner')) {
$currency = $repository->store($data);
Session::flash('success', 'Currency "' . $currency->name . '" created');
}
if (intval(Input::get('create_another')) === 1) {
Session::put('currency.create.fromStore', true);
@ -185,9 +193,10 @@ class CurrencyController extends Controller
*/
public function update(CurrencyFormRequest $request, CurrencyRepositoryInterface $repository, TransactionCurrency $currency)
{
$data = $request->getCurrencyData();
$currency = $repository->update($currency, $data);
$data = $request->getCurrencyData();
if (Auth::user()->hasRole('owner')) {
$currency = $repository->update($currency, $data);
}
Session::flash('success', 'Currency "' . e($currency->name) . '" updated.');

14
app/Models/Permission.php Normal file
View File

@ -0,0 +1,14 @@
<?php
namespace FireflyIII\Models;
use Zizaco\Entrust\EntrustPermission;
/**
* Class Permission
*
* @package FireflyIII\Models
*/
class Permission extends EntrustPermission
{
}

14
app/Models/Role.php Normal file
View File

@ -0,0 +1,14 @@
<?php
namespace FireflyIII\Models;
use Zizaco\Entrust\EntrustRole;
/**
* Class Role
*
* @package FireflyIII\Models
*/
class Role extends EntrustRole
{
}

View File

@ -5,6 +5,7 @@ use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
use Illuminate\Database\Eloquent\Model;
use Zizaco\Entrust\Traits\EntrustUserTrait;
/**
* Class User
@ -36,7 +37,7 @@ use Illuminate\Database\Eloquent\Model;
class User extends Model implements AuthenticatableContract, CanResetPasswordContract
{
use Authenticatable, CanResetPassword;
use Authenticatable, CanResetPassword, EntrustUserTrait;
/**
* The attributes that are mass assignable.

View File

@ -28,7 +28,8 @@
"illuminate/html": "~5.0",
"league/commonmark": "0.7.*",
"rcrowe/twigbridge": "0.7.x@dev",
"twig/extensions": "~1.2"
"twig/extensions": "~1.2",
"zizaco/entrust": "dev-laravel-5"
},
"require-dev": {
"barryvdh/laravel-debugbar": "@stable",

346
composer.lock generated
View File

@ -4,24 +4,24 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "46b7813f499f70942e9997e916e68145",
"hash": "a0c92aa0223617ca2730500921bdd82c",
"packages": [
{
"name": "classpreloader/classpreloader",
"version": "1.3.0",
"version": "1.4.0",
"source": {
"type": "git",
"url": "https://github.com/ClassPreloader/ClassPreloader.git",
"reference": "0544616ba33fb2a6b792b3a7822650810c6d65d9"
"reference": "b76f3f4f603ebbe7e64351a7ef973431ddaf7b27"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ClassPreloader/ClassPreloader/zipball/0544616ba33fb2a6b792b3a7822650810c6d65d9",
"reference": "0544616ba33fb2a6b792b3a7822650810c6d65d9",
"url": "https://api.github.com/repos/ClassPreloader/ClassPreloader/zipball/b76f3f4f603ebbe7e64351a7ef973431ddaf7b27",
"reference": "b76f3f4f603ebbe7e64351a7ef973431ddaf7b27",
"shasum": ""
},
"require": {
"nikic/php-parser": "^1.2.2",
"nikic/php-parser": "~1.3",
"php": ">=5.3.3",
"symfony/console": "~2.1",
"symfony/filesystem": "~2.1",
@ -36,7 +36,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.3-dev"
"dev-master": "1.4-dev"
}
},
"autoload": {
@ -49,13 +49,13 @@
"MIT"
],
"authors": [
{
"name": "Graham Campbell",
"email": "graham@mineuk.com"
},
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com"
},
{
"name": "Graham Campbell",
"email": "graham@cachethq.io"
}
],
"description": "Helps class loading performance by generating a single PHP file containing all of the autoloaded files for a specific use case",
@ -64,7 +64,7 @@
"class",
"preload"
],
"time": "2015-04-15 21:59:30"
"time": "2015-05-26 10:57:51"
},
{
"name": "danielstjules/stringy",
@ -673,54 +673,6 @@
],
"time": "2014-09-09 13:34:57"
},
{
"name": "fzaninotto/faker",
"version": "v1.4.0",
"source": {
"type": "git",
"url": "https://github.com/fzaninotto/Faker.git",
"reference": "010c7efedd88bf31141a02719f51fb44c732d5a0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fzaninotto/Faker/zipball/010c7efedd88bf31141a02719f51fb44c732d5a0",
"reference": "010c7efedd88bf31141a02719f51fb44c732d5a0",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"squizlabs/php_codesniffer": "~1.5"
},
"type": "library",
"extra": {
"branch-alias": []
},
"autoload": {
"psr-0": {
"Faker": "src/",
"Faker\\PHPUnit": "test/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "François Zaninotto"
}
],
"description": "Faker is a PHP library that generates fake data for you.",
"keywords": [
"data",
"faker",
"fixtures"
],
"time": "2014-06-04 14:43:02"
},
{
"name": "grumpydictator/gchart",
"version": "1.0.9",
@ -1693,17 +1645,17 @@
},
{
"name": "symfony/console",
"version": "v2.6.7",
"version": "v2.6.8",
"target-dir": "Symfony/Component/Console",
"source": {
"type": "git",
"url": "https://github.com/symfony/Console.git",
"reference": "ebc5679854aa24ed7d65062e9e3ab0b18a917272"
"reference": "2343f6d8026306bd330e0c987e4c102483c213e7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Console/zipball/ebc5679854aa24ed7d65062e9e3ab0b18a917272",
"reference": "ebc5679854aa24ed7d65062e9e3ab0b18a917272",
"url": "https://api.github.com/repos/symfony/Console/zipball/2343f6d8026306bd330e0c987e4c102483c213e7",
"reference": "2343f6d8026306bd330e0c987e4c102483c213e7",
"shasum": ""
},
"require": {
@ -1747,21 +1699,21 @@
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
"time": "2015-05-02 15:18:45"
"time": "2015-05-22 14:53:08"
},
{
"name": "symfony/debug",
"version": "v2.6.7",
"version": "v2.6.8",
"target-dir": "Symfony/Component/Debug",
"source": {
"type": "git",
"url": "https://github.com/symfony/Debug.git",
"reference": "ad4511a8fddce7ec163b513ba39a30ea4f32c9e7"
"reference": "4851a041c48e76b91a221db84ab5850daa6a7b33"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Debug/zipball/ad4511a8fddce7ec163b513ba39a30ea4f32c9e7",
"reference": "ad4511a8fddce7ec163b513ba39a30ea4f32c9e7",
"url": "https://api.github.com/repos/symfony/Debug/zipball/4851a041c48e76b91a221db84ab5850daa6a7b33",
"reference": "4851a041c48e76b91a221db84ab5850daa6a7b33",
"shasum": ""
},
"require": {
@ -1808,11 +1760,11 @@
],
"description": "Symfony Debug Component",
"homepage": "https://symfony.com",
"time": "2015-05-08 13:17:44"
"time": "2015-05-20 13:09:45"
},
{
"name": "symfony/event-dispatcher",
"version": "v2.6.7",
"version": "v2.6.8",
"target-dir": "Symfony/Component/EventDispatcher",
"source": {
"type": "git",
@ -1871,17 +1823,17 @@
},
{
"name": "symfony/filesystem",
"version": "v2.6.7",
"version": "v2.6.8",
"target-dir": "Symfony/Component/Filesystem",
"source": {
"type": "git",
"url": "https://github.com/symfony/Filesystem.git",
"reference": "f73904bd2dae525c42ea1f0340c7c98480ecacde"
"reference": "1f8429f72a5bfa58b33fd96824bea146fc4b3f49"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Filesystem/zipball/f73904bd2dae525c42ea1f0340c7c98480ecacde",
"reference": "f73904bd2dae525c42ea1f0340c7c98480ecacde",
"url": "https://api.github.com/repos/symfony/Filesystem/zipball/1f8429f72a5bfa58b33fd96824bea146fc4b3f49",
"reference": "1f8429f72a5bfa58b33fd96824bea146fc4b3f49",
"shasum": ""
},
"require": {
@ -1917,21 +1869,21 @@
],
"description": "Symfony Filesystem Component",
"homepage": "https://symfony.com",
"time": "2015-05-08 00:09:07"
"time": "2015-05-15 13:32:45"
},
{
"name": "symfony/finder",
"version": "v2.6.7",
"version": "v2.6.8",
"target-dir": "Symfony/Component/Finder",
"source": {
"type": "git",
"url": "https://github.com/symfony/Finder.git",
"reference": "704c64c8b12c8882640d5c0330a8414b1e06dc99"
"reference": "ffedd3e0ff8155188155e9322fe21b9ee012ac14"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Finder/zipball/704c64c8b12c8882640d5c0330a8414b1e06dc99",
"reference": "704c64c8b12c8882640d5c0330a8414b1e06dc99",
"url": "https://api.github.com/repos/symfony/Finder/zipball/ffedd3e0ff8155188155e9322fe21b9ee012ac14",
"reference": "ffedd3e0ff8155188155e9322fe21b9ee012ac14",
"shasum": ""
},
"require": {
@ -1967,21 +1919,21 @@
],
"description": "Symfony Finder Component",
"homepage": "https://symfony.com",
"time": "2015-05-02 15:18:45"
"time": "2015-05-15 13:32:45"
},
{
"name": "symfony/http-foundation",
"version": "v2.6.7",
"version": "v2.6.8",
"target-dir": "Symfony/Component/HttpFoundation",
"source": {
"type": "git",
"url": "https://github.com/symfony/HttpFoundation.git",
"reference": "8a0d00980ef9f6b47ddbf24bdfbf70fead760816"
"reference": "f9b28dcc6d3e50f5568b42dda7292656a9fe8432"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/8a0d00980ef9f6b47ddbf24bdfbf70fead760816",
"reference": "8a0d00980ef9f6b47ddbf24bdfbf70fead760816",
"url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/f9b28dcc6d3e50f5568b42dda7292656a9fe8432",
"reference": "f9b28dcc6d3e50f5568b42dda7292656a9fe8432",
"shasum": ""
},
"require": {
@ -2021,21 +1973,21 @@
],
"description": "Symfony HttpFoundation Component",
"homepage": "https://symfony.com",
"time": "2015-05-02 15:18:45"
"time": "2015-05-22 14:53:08"
},
{
"name": "symfony/http-kernel",
"version": "v2.6.7",
"version": "v2.6.8",
"target-dir": "Symfony/Component/HttpKernel",
"source": {
"type": "git",
"url": "https://github.com/symfony/HttpKernel.git",
"reference": "2010194de0a57731af9404c7f97fd300db98b7a3"
"reference": "a9a6f595941fce8dddd64f4e9bf47747cf1515fc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/HttpKernel/zipball/2010194de0a57731af9404c7f97fd300db98b7a3",
"reference": "2010194de0a57731af9404c7f97fd300db98b7a3",
"url": "https://api.github.com/repos/symfony/HttpKernel/zipball/a9a6f595941fce8dddd64f4e9bf47747cf1515fc",
"reference": "a9a6f595941fce8dddd64f4e9bf47747cf1515fc",
"shasum": ""
},
"require": {
@ -2099,21 +2051,21 @@
],
"description": "Symfony HttpKernel Component",
"homepage": "https://symfony.com",
"time": "2015-05-11 01:58:49"
"time": "2015-05-27 00:17:10"
},
{
"name": "symfony/process",
"version": "v2.6.7",
"version": "v2.6.8",
"target-dir": "Symfony/Component/Process",
"source": {
"type": "git",
"url": "https://github.com/symfony/Process.git",
"reference": "9f3c4baaf840ed849e1b1f7bfd5ae246e8509562"
"reference": "7856d78ab6cce6e59d02d9e1a873441f6bd21306"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Process/zipball/9f3c4baaf840ed849e1b1f7bfd5ae246e8509562",
"reference": "9f3c4baaf840ed849e1b1f7bfd5ae246e8509562",
"url": "https://api.github.com/repos/symfony/Process/zipball/7856d78ab6cce6e59d02d9e1a873441f6bd21306",
"reference": "7856d78ab6cce6e59d02d9e1a873441f6bd21306",
"shasum": ""
},
"require": {
@ -2149,21 +2101,21 @@
],
"description": "Symfony Process Component",
"homepage": "https://symfony.com",
"time": "2015-05-02 15:18:45"
"time": "2015-05-15 13:32:45"
},
{
"name": "symfony/routing",
"version": "v2.6.7",
"version": "v2.6.8",
"target-dir": "Symfony/Component/Routing",
"source": {
"type": "git",
"url": "https://github.com/symfony/Routing.git",
"reference": "1455ec537940f7428ea6aa9411f3c4bca69413a0"
"reference": "dc9df18a1cfe87de65e270e8f01407ca6d7c39cb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Routing/zipball/1455ec537940f7428ea6aa9411f3c4bca69413a0",
"reference": "1455ec537940f7428ea6aa9411f3c4bca69413a0",
"url": "https://api.github.com/repos/symfony/Routing/zipball/dc9df18a1cfe87de65e270e8f01407ca6d7c39cb",
"reference": "dc9df18a1cfe87de65e270e8f01407ca6d7c39cb",
"shasum": ""
},
"require": {
@ -2218,21 +2170,21 @@
"uri",
"url"
],
"time": "2015-05-02 15:18:45"
"time": "2015-05-15 13:32:45"
},
{
"name": "symfony/security-core",
"version": "v2.6.7",
"version": "v2.6.8",
"target-dir": "Symfony/Component/Security/Core",
"source": {
"type": "git",
"url": "https://github.com/symfony/security-core.git",
"reference": "d25c17db741f58c0f615e52006a47f6fb23cd9b3"
"reference": "1ad0ee4b2a1ab32924cd0be397f0196b5d47e5d0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/security-core/zipball/d25c17db741f58c0f615e52006a47f6fb23cd9b3",
"reference": "d25c17db741f58c0f615e52006a47f6fb23cd9b3",
"url": "https://api.github.com/repos/symfony/security-core/zipball/1ad0ee4b2a1ab32924cd0be397f0196b5d47e5d0",
"reference": "1ad0ee4b2a1ab32924cd0be397f0196b5d47e5d0",
"shasum": ""
},
"require": {
@ -2271,32 +2223,32 @@
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
},
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Security Component - Core Library",
"homepage": "http://symfony.com",
"time": "2015-03-30 15:54:10"
"homepage": "https://symfony.com",
"time": "2015-05-15 13:53:19"
},
{
"name": "symfony/translation",
"version": "v2.6.7",
"version": "v2.6.8",
"target-dir": "Symfony/Component/Translation",
"source": {
"type": "git",
"url": "https://github.com/symfony/Translation.git",
"reference": "398e0eedcb89243ad34a10d079a4b6ea4c0b61ff"
"reference": "d030b3d8d9699795dbf8c59e915ef879007a4483"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Translation/zipball/398e0eedcb89243ad34a10d079a4b6ea4c0b61ff",
"reference": "398e0eedcb89243ad34a10d079a4b6ea4c0b61ff",
"url": "https://api.github.com/repos/symfony/Translation/zipball/d030b3d8d9699795dbf8c59e915ef879007a4483",
"reference": "d030b3d8d9699795dbf8c59e915ef879007a4483",
"shasum": ""
},
"require": {
@ -2341,11 +2293,11 @@
],
"description": "Symfony Translation Component",
"homepage": "https://symfony.com",
"time": "2015-05-05 16:51:00"
"time": "2015-05-22 14:37:51"
},
{
"name": "symfony/var-dumper",
"version": "v2.6.7",
"version": "v2.6.8",
"target-dir": "Symfony/Component/VarDumper",
"source": {
"type": "git",
@ -2617,6 +2569,73 @@
"validation"
],
"time": "2015-05-23 00:03:54"
},
{
"name": "zizaco/entrust",
"version": "dev-laravel-5",
"source": {
"type": "git",
"url": "https://github.com/Zizaco/entrust.git",
"reference": "804000c1c535221792b4e173ecdcc02b5681f5ec"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Zizaco/entrust/zipball/804000c1c535221792b4e173ecdcc02b5681f5ec",
"reference": "804000c1c535221792b4e173ecdcc02b5681f5ec",
"shasum": ""
},
"require": {
"illuminate/console": "~5.0",
"illuminate/support": "~5.0",
"php": ">=5.4.0"
},
"require-dev": {
"illuminate/database": "~5.0",
"mockery/mockery": "dev-master",
"phpunit/phpunit": "~4.1",
"sami/sami": "dev-master"
},
"type": "library",
"autoload": {
"classmap": [
"src/commands"
],
"psr-4": {
"Zizaco\\Entrust\\": "src/Entrust/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Andrew Elkins",
"homepage": "http://andrewelkins.com"
},
{
"name": "Zizaco Zizuini",
"email": "zizaco@gmail.com"
},
{
"name": "Ben Batschelet",
"homepage": "http://github.com/bbatsche"
},
{
"name": "Michele Angioni",
"email": "michele.angioni@gmail.com"
}
],
"description": "This package provides a flexible way to add Role-based Permissions to Laravel",
"keywords": [
"acl",
"auth",
"illuminate",
"laravel",
"permission",
"roles"
],
"time": "2015-05-25 00:17:51"
}
],
"packages-dev": [
@ -2848,6 +2867,54 @@
],
"time": "2014-10-13 12:58:55"
},
{
"name": "fzaninotto/faker",
"version": "v1.4.0",
"source": {
"type": "git",
"url": "https://github.com/fzaninotto/Faker.git",
"reference": "010c7efedd88bf31141a02719f51fb44c732d5a0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fzaninotto/Faker/zipball/010c7efedd88bf31141a02719f51fb44c732d5a0",
"reference": "010c7efedd88bf31141a02719f51fb44c732d5a0",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"squizlabs/php_codesniffer": "~1.5"
},
"type": "library",
"extra": {
"branch-alias": []
},
"autoload": {
"psr-0": {
"Faker": "src/",
"Faker\\PHPUnit": "test/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "François Zaninotto"
}
],
"description": "Faker is a PHP library that generates fake data for you.",
"keywords": [
"data",
"faker",
"fixtures"
],
"time": "2014-06-04 14:43:02"
},
{
"name": "guzzle/guzzle",
"version": "v3.9.3",
@ -3393,16 +3460,16 @@
},
{
"name": "phpunit/php-code-coverage",
"version": "2.0.16",
"version": "2.0.17",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "934fd03eb6840508231a7f73eb8940cf32c3b66c"
"reference": "c4e8e7725e351184a76544634855b8a9c405a6e3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/934fd03eb6840508231a7f73eb8940cf32c3b66c",
"reference": "934fd03eb6840508231a7f73eb8940cf32c3b66c",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/c4e8e7725e351184a76544634855b8a9c405a6e3",
"reference": "c4e8e7725e351184a76544634855b8a9c405a6e3",
"shasum": ""
},
"require": {
@ -3451,7 +3518,7 @@
"testing",
"xunit"
],
"time": "2015-04-11 04:35:00"
"time": "2015-05-25 05:11:59"
},
{
"name": "phpunit/php-file-iterator",
@ -3639,16 +3706,16 @@
},
{
"name": "phpunit/phpunit",
"version": "4.6.6",
"version": "4.6.7",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "3afe303d873a4d64c62ef84de491b97b006fbdac"
"reference": "57bf06dd4eebe2a5ced79a8de71509e7d5c18b25"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3afe303d873a4d64c62ef84de491b97b006fbdac",
"reference": "3afe303d873a4d64c62ef84de491b97b006fbdac",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/57bf06dd4eebe2a5ced79a8de71509e7d5c18b25",
"reference": "57bf06dd4eebe2a5ced79a8de71509e7d5c18b25",
"shasum": ""
},
"require": {
@ -3707,7 +3774,7 @@
"testing",
"xunit"
],
"time": "2015-04-29 15:18:52"
"time": "2015-05-25 05:18:18"
},
{
"name": "phpunit/phpunit-mock-objects",
@ -4205,17 +4272,17 @@
},
{
"name": "symfony/class-loader",
"version": "v2.6.7",
"version": "v2.6.8",
"target-dir": "Symfony/Component/ClassLoader",
"source": {
"type": "git",
"url": "https://github.com/symfony/ClassLoader.git",
"reference": "695134c9b39559297fa5d1dcff6a9054bb56facb"
"reference": "abf5632a31402ae6ac19cd00683faf603046440a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/ClassLoader/zipball/695134c9b39559297fa5d1dcff6a9054bb56facb",
"reference": "695134c9b39559297fa5d1dcff6a9054bb56facb",
"url": "https://api.github.com/repos/symfony/ClassLoader/zipball/abf5632a31402ae6ac19cd00683faf603046440a",
"reference": "abf5632a31402ae6ac19cd00683faf603046440a",
"shasum": ""
},
"require": {
@ -4252,21 +4319,21 @@
],
"description": "Symfony ClassLoader Component",
"homepage": "https://symfony.com",
"time": "2015-05-02 15:18:45"
"time": "2015-05-15 13:32:45"
},
{
"name": "symfony/config",
"version": "v2.6.7",
"version": "v2.6.8",
"target-dir": "Symfony/Component/Config",
"source": {
"type": "git",
"url": "https://github.com/symfony/Config.git",
"reference": "b6fddb4aa2daaa2b06f0040071ac131b4a1ecf25"
"reference": "2696c5bc7c31485a482c10865d713de9fcc7aa31"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Config/zipball/b6fddb4aa2daaa2b06f0040071ac131b4a1ecf25",
"reference": "b6fddb4aa2daaa2b06f0040071ac131b4a1ecf25",
"url": "https://api.github.com/repos/symfony/Config/zipball/2696c5bc7c31485a482c10865d713de9fcc7aa31",
"reference": "2696c5bc7c31485a482c10865d713de9fcc7aa31",
"shasum": ""
},
"require": {
@ -4303,11 +4370,11 @@
],
"description": "Symfony Config Component",
"homepage": "https://symfony.com",
"time": "2015-05-02 15:18:45"
"time": "2015-05-15 13:32:45"
},
{
"name": "symfony/stopwatch",
"version": "v2.6.7",
"version": "v2.6.8",
"target-dir": "Symfony/Component/Stopwatch",
"source": {
"type": "git",
@ -4357,7 +4424,7 @@
},
{
"name": "symfony/yaml",
"version": "v2.6.7",
"version": "v2.6.8",
"target-dir": "Symfony/Component/Yaml",
"source": {
"type": "git",
@ -4410,6 +4477,7 @@
"minimum-stability": "stable",
"stability-flags": {
"rcrowe/twigbridge": 20,
"zizaco/entrust": 20,
"barryvdh/laravel-debugbar": 0
},
"prefer-stable": false,

View File

@ -139,8 +139,9 @@ return [
'TwigBridge\ServiceProvider',
'DaveJamesMiller\Breadcrumbs\ServiceProvider',
'Barryvdh\Debugbar\ServiceProvider',
'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider',
// 'Barryvdh\Debugbar\ServiceProvider',
// 'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider',
'Zizaco\Entrust\EntrustServiceProvider',
/*
* Application Service Providers...
@ -210,6 +211,7 @@ return [
'Steam' => 'FireflyIII\Support\Facades\Steam',
'ExpandedForm' => 'FireflyIII\Support\Facades\ExpandedForm',
'Twig' => 'TwigBridge\Facade\Twig',
'Entrust' => 'Zizaco\Entrust\EntrustFacade'
],

7
config/breadcrumbs.php Normal file
View File

@ -0,0 +1,7 @@
<?php
return [
'view' => 'breadcrumbs::bootstrap3',
];

78
config/entrust.php Normal file
View File

@ -0,0 +1,78 @@
<?php
/**
* This file is part of Entrust,
* a role & permission management solution for Laravel.
*
* @license MIT
* @package Zizaco\Entrust
*/
return [
/*
|--------------------------------------------------------------------------
| Entrust Role Model
|--------------------------------------------------------------------------
|
| This is the Role model used by Entrust to create correct relations. Update
| the role if it is in a different namespace.
|
*/
'role' => 'FireflyIII\Models\Role',
/*
|--------------------------------------------------------------------------
| Entrust Roles Table
|--------------------------------------------------------------------------
|
| This is the roles table used by Entrust to save roles to the database.
|
*/
'roles_table' => 'roles',
/*
|--------------------------------------------------------------------------
| Entrust Permission Model
|--------------------------------------------------------------------------
|
| This is the Permission model used by Entrust to create correct relations.
| Update the permission if it is in a different namespace.
|
*/
'permission' => 'FireflyIII\Models\Permission',
/*
|--------------------------------------------------------------------------
| Entrust Permissions Table
|--------------------------------------------------------------------------
|
| This is the permissions table used by Entrust to save permissions to the
| database.
|
*/
'permissions_table' => 'permissions',
/*
|--------------------------------------------------------------------------
| Entrust permission_role Table
|--------------------------------------------------------------------------
|
| This is the permission_role table used by Entrust to save relationship
| between permissions and roles to the database.
|
*/
'permission_role_table' => 'permission_role',
/*
|--------------------------------------------------------------------------
| Entrust role_user Table
|--------------------------------------------------------------------------
|
| This is the role_user table used by Entrust to save assigned roles to the
| database.
|
*/
'role_user_table' => 'role_user',
];

View File

@ -0,0 +1,74 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
/**
* Class EntrustSetupTables
*/
class EntrustSetupTables extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
// Create table for storing roles
Schema::create('roles', function (Blueprint $table) {
$table->increments('id');
$table->string('name')->unique();
$table->string('display_name')->nullable();
$table->string('description')->nullable();
$table->timestamps();
});
// Create table for associating roles to users (Many-to-Many)
Schema::create('role_user', function (Blueprint $table) {
$table->integer('user_id')->unsigned();
$table->integer('role_id')->unsigned();
$table->foreign('user_id')->references('id')->on('users')
->onUpdate('cascade')->onDelete('cascade');
$table->foreign('role_id')->references('id')->on('roles')
->onUpdate('cascade')->onDelete('cascade');
$table->primary(['user_id', 'role_id']);
});
// Create table for storing permissions
Schema::create('permissions', function (Blueprint $table) {
$table->increments('id');
$table->string('name')->unique();
$table->string('display_name')->nullable();
$table->string('description')->nullable();
$table->timestamps();
});
// Create table for associating permissions to roles (Many-to-Many)
Schema::create('permission_role', function (Blueprint $table) {
$table->integer('permission_id')->unsigned();
$table->integer('role_id')->unsigned();
$table->foreign('permission_id')->references('id')->on('permissions')
->onUpdate('cascade')->onDelete('cascade');
$table->foreign('role_id')->references('id')->on('roles')
->onUpdate('cascade')->onDelete('cascade');
$table->primary(['permission_id', 'role_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('permission_role');
Schema::drop('permissions');
Schema::drop('role_user');
Schema::drop('roles');
}
}

View File

@ -20,6 +20,7 @@ class DatabaseSeeder extends Seeder
$this->call('AccountTypeSeeder');
$this->call('TransactionCurrencySeeder');
$this->call('TransactionTypeSeeder');
$this->call('PermissionSeeder');
if (App::environment() == 'testing' || App::environment() == 'homestead' || gethostname() == 'vagrant-firefly-iii') {
$this->call('TestDataSeeder');

View File

@ -0,0 +1,21 @@
<?php
use FireflyIII\Models\Role;
use Illuminate\Database\Seeder;
/**
* Class PermissionSeeder
*/
class PermissionSeeder extends Seeder
{
public function run()
{
$owner = new Role;
$owner->name = 'owner';
$owner->display_name = 'Site Owner';
$owner->description = 'User runs this instance of FF3'; // optional
$owner->save();
}
}

View File

@ -108,6 +108,11 @@ class CurrencyControllerTest extends TestCase
public function testDestroy()
{
$user = FactoryMuffin::create('FireflyIII\User');
$role = FactoryMuffin::create('FireflyIII\Models\Role');
$role->name = 'owner';
$role->save();
$user->attachRole($role);
$this->be($user);
$currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
@ -126,6 +131,10 @@ class CurrencyControllerTest extends TestCase
public function testDestroyUnable()
{
$user = FactoryMuffin::create('FireflyIII\User');
$role = FactoryMuffin::create('FireflyIII\Models\Role');
$role->name = 'owner';
$role->save();
$user->attachRole($role);
$this->be($user);
$currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
@ -178,6 +187,10 @@ class CurrencyControllerTest extends TestCase
public function testStore()
{
$user = FactoryMuffin::create('FireflyIII\User');
$role = FactoryMuffin::create('FireflyIII\Models\Role');
$role->name = 'owner';
$role->save();
$user->attachRole($role);
$currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
$this->be($user);
@ -199,6 +212,10 @@ class CurrencyControllerTest extends TestCase
public function testStoreAndReturn()
{
$user = FactoryMuffin::create('FireflyIII\User');
$role = FactoryMuffin::create('FireflyIII\Models\Role');
$role->name = 'owner';
$role->save();
$user->attachRole($role);
$currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
$this->be($user);
@ -220,6 +237,10 @@ class CurrencyControllerTest extends TestCase
public function testUpdate()
{
$user = FactoryMuffin::create('FireflyIII\User');
$role = FactoryMuffin::create('FireflyIII\Models\Role');
$role->name = 'owner';
$role->save();
$user->attachRole($role);
$currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
$this->be($user);
@ -239,6 +260,10 @@ class CurrencyControllerTest extends TestCase
public function testUpdateAndReturn()
{
$user = FactoryMuffin::create('FireflyIII\User');
$role = FactoryMuffin::create('FireflyIII\Models\Role');
$role->name = 'owner';
$role->save();
$user->attachRole($role);
$currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
$this->be($user);

View File

@ -29,6 +29,13 @@ if (!class_exists('RandomString')) {
}
}
FactoryMuffin::define(
'FireflyIII\Models\Role',
[
'name' => 'word',
]
);
FactoryMuffin::define(
'FireflyIII\Models\Bill',
[