Commit 6994f095 authored by Nicolas Widart's avatar Nicolas Widart

Squashed 'Modules/User/' changes from 6206740..8b9a95b

8b9a95b Removing unused dependency
24c7042 Back to abstract class
76219fe Removing the session dependency
66d02c4 Moving the private variable up
7f309c3 Moving the permissions manager one class up
57c0859 Removing unused variable. Refactoring one more method
42c5a2c Refactoring User tests
bae983e Refactoring the Session test
2c9a00b Abstracting the permision partial
2786996 Removing duplicate partial views
7679dfc Type hinting for array
c7e5050 Reactivating the guest filter
a656b76 Removing duplicate role request
45e5b9e Astracting the method
1fedb02 Fixing code duplication
57f57a0 Removing unused import
fc62d29 Removing unused variable
1c68458 Type hinting for the message class
6085e7d Type hinting view class
3b7aaf1 Adding blank line at EOL
fdf1b94 Removing unused helper. Switcher functions to class calls
de0a4f9 Testing new middleware
7491ecc Adding code quality badges
a5c6767 Merge pull request #10 from nWidart-Modules/conforming-to-l5
95558c7 Removing annotations to be sure.
75041d2 New routes SP structure.
a019da9 Adding namespace back to routes file

git-subtree-dir: Modules/User
git-subtree-split: 8b9a95b378ee5d88d1a7112702bc2c25ecd200e3
parent e3d775c7
......@@ -2,10 +2,11 @@
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Request;
use Illuminate\View\View;
class SidebarViewComposer
{
public function compose($view)
public function compose(View $view)
{
$view->items->put('user', Collection::make([
[
......
<?php namespace Modules\User\Http\Controllers\Admin;
use Modules\Core\Http\Controllers\Admin\AdminBaseController;
abstract class BaseUserModuleController extends AdminBaseController
{
/**
* @var PermissionManager
*/
protected $permissions;
/**
* @param $request
* @return array
*/
protected function mergeRequestWithPermissions($request)
{
return array_merge($request->all(), ['permissions' => $this->permissions->clean($request->permissions)]);
}
}
......@@ -3,18 +3,12 @@
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\View;
use Laracasts\Flash\Flash;
use Modules\Core\Http\Controllers\Admin\AdminBaseController;
use Modules\Core\Permissions\PermissionManager;
use Modules\User\Http\Requests\CreateRolesRequest;
use Modules\User\Http\Requests\UpdateRoleRequest;
use Modules\User\Http\Requests\RolesRequest;
use Modules\User\Repositories\RoleRepository;
class RolesController extends AdminBaseController
class RolesController extends BaseUserModuleController
{
/**
* @var PermissionManager
*/
private $permissions;
/**
* @var RoleRepository
*/
......@@ -23,6 +17,7 @@ class RolesController extends AdminBaseController
public function __construct(PermissionManager $permissions, RoleRepository $role)
{
parent::__construct();
$this->permissions = $permissions;
$this->role = $role;
}
......@@ -52,12 +47,12 @@ class RolesController extends AdminBaseController
/**
* Store a newly created resource in storage.
*
* @param CreateRolesRequest $request
* @param RolesRequest $request
* @return Response
*/
public function store(CreateRolesRequest $request)
public function store(RolesRequest $request)
{
$data = array_merge($request->all(), ['permissions' => $this->permissions->clean($request->permissions)]);
$data = $this->mergeRequestWithPermissions($request);
$this->role->create($data);
......@@ -84,12 +79,12 @@ class RolesController extends AdminBaseController
* Update the specified resource in storage.
*
* @param int $id
* @param UpdateRoleRequest $request
* @param RolesRequest $request
* @return Response
*/
public function update($id, UpdateRoleRequest $request)
public function update($id, RolesRequest $request)
{
$data = array_merge($request->all(), ['permissions' => $this->permissions->clean($request->permissions)]);
$data = $this->mergeRequestWithPermissions($request);
$this->role->update($id, $data);
......@@ -110,4 +105,5 @@ class RolesController extends AdminBaseController
Flash::success('Role deleted!');
return Redirect::route('dashboard.role.index');
}
}
......@@ -3,19 +3,14 @@
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\View;
use Laracasts\Flash\Flash;
use Modules\Core\Http\Controllers\Admin\AdminBaseController;
use Modules\Core\Permissions\PermissionManager;
use Modules\User\Http\Requests\CreateUserRequest;
use Modules\User\Http\Requests\UpdateUserRequest;
use Modules\User\Repositories\RoleRepository;
use Modules\User\Repositories\UserRepository;
class UserController extends AdminBaseController
class UserController extends BaseUserModuleController
{
/**
* @var PermissionManager
*/
private $permissions;
/**
* @var UserRepository
*/
......@@ -66,7 +61,7 @@ class UserController extends AdminBaseController
*/
public function store(CreateUserRequest $request)
{
$data = array_merge($request->all(), ['permissions' => $this->permissions->clean($request->permissions)]);
$data = $this->mergeRequestWithPermissions($request);
$this->user->createWithRoles($data, $request->roles);
......@@ -100,7 +95,7 @@ class UserController extends AdminBaseController
*/
public function update($id, UpdateUserRequest $request)
{
$data = array_merge($request->all(), ['permissions' => $this->permissions->clean($request->permissions)]);
$data = $this->mergeRequestWithPermissions($request);
$this->user->updateAndSyncRoles($id, $data, $request->roles);
......
......@@ -14,10 +14,6 @@ use Modules\User\Http\Requests\RegisterRequest;
use Modules\User\Http\Requests\ResetCompleteRequest;
use Modules\User\Http\Requests\ResetRequest;
/**
* @Controller()
* @Before("auth.guest", on={"getLogin", "getRegister"})
*/
class AuthController
{
use CommanderTrait;
......@@ -39,7 +35,7 @@ class AuthController
];
$remember = (bool)$request->get('remember_me', false);
try {
if ($user = Sentinel::authenticate($credentials, $remember)) {
if (Sentinel::authenticate($credentials, $remember)) {
Flash::success('Successfully logged in.');
return Redirect::route('dashboard.index', compact('user'));
}
......
<?php namespace Modules\User\Http\Middleware;
use Cartalyst\Sentinel\Laravel\Facades\Sentinel;
use Closure;
use Illuminate\Contracts\Routing\Middleware;
use Illuminate\Support\Facades\Redirect;
class GuestMiddleware implements Middleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
dd('ok?');
if (Sentinel::check()) {
return Redirect::route('dashboard.index');
}
}
}
<?php namespace Modules\User\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class CreateRolesRequest extends FormRequest
{
public function rules()
{
return [
'name' => 'required',
'slug' => 'required',
];
}
public function authorize()
{
return true;
}
public function messages()
{
return [];
}
}
\ No newline at end of file
......@@ -2,7 +2,7 @@
use Illuminate\Foundation\Http\FormRequest;
class UpdateRoleRequest extends FormRequest
class RolesRequest extends FormRequest
{
public function rules()
{
......
......@@ -2,7 +2,7 @@
$router->group(['prefix' => LaravelLocalization::setLocale(), 'before' => 'LaravelLocalizationRedirectFilter|auth.admin|permissions'], function($router)
{
$router->group(['prefix' => Config::get('core::core.admin-prefix')], function($router)
$router->group(['prefix' => Config::get('core::core.admin-prefix'), 'namespace' => 'Modules\User\Http\Controllers'], function($router)
{
$router->resource('users', 'Admin\UserController', ['except' => ['show'], 'names' => [
'index' => 'dashboard.user.index',
......@@ -23,7 +23,7 @@ $router->group(['prefix' => LaravelLocalization::setLocale(), 'before' => 'Larav
});
});
$router->group(['prefix' => 'auth'], function($router)
$router->group(['prefix' => 'auth', 'namespace' => 'Modules\User\Http\Controllers'], function($router)
{
# Login
$router->get('login', ['before' => 'auth.guest', 'as' => 'login', 'uses' => 'AuthController@getLogin']);
......
<?php namespace Modules\User\Listeners;
use Cartalyst\Sentinel\Laravel\Facades\Activation;
use Illuminate\Mail\Message;
use Illuminate\Support\Facades\Mail;
use Laracasts\Commander\Events\EventListener;
......@@ -16,7 +17,7 @@ class SendRegistrationConfirmationEmail extends EventListener
'activationcode' => $activation->code
];
Mail::queue('session::emails.welcome',$data,
function ($m) use ($user) {
function (Message $m) use ($user) {
$m->to($user->email)->subject('Welcome.');
}
);
......
<?php namespace Modules\User\Listeners;
use Illuminate\Mail\Message;
use Illuminate\Support\Facades\Mail;
use Laracasts\Commander\Events\EventListener;
......@@ -10,7 +11,7 @@ class SendResetCodeEmail extends EventListener
$user = $event->user;
$code = $event->reminder->code;
Mail::queue('SessionModule::emails.reminder', compact('user', 'code'), function($m) use ($user)
Mail::queue('SessionModule::emails.reminder', compact('user', 'code'), function(Message $m) use ($user)
{
$m->to($user->email)->subject('Reset your account password.');
});
......
<?php namespace Modules\User\Providers;
use Illuminate\Routing\Router;
use Illuminate\Contracts\Routing\UrlGenerator;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
class RouteServiceProvider extends ServiceProvider
{
/**
* The root namespace to assume when generating URLs to actions.
*
* @var string
*/
protected $rootUrlNamespace = 'Modules\User\Http\Controllers';
/**
* The controllers to scan for route annotations.
*
* @var array
*/
protected $scan = [
'Modules\User\Http\Controllers',
];
/**
* Called before routes are registered.
*
* Register any model bindings or pattern based filters.
*
* @param Router $router
* @param UrlGenerator $url
* @return void
*/
public function before(Router $router, UrlGenerator $url)
public function before(Router $router)
{
$url->setRootControllerNamespace('Modules\User\Http\Controllers');
//
}
/**
......@@ -25,14 +39,9 @@ class RouteServiceProvider extends ServiceProvider
*
* @return void
*/
public function map()
{
$this->app->booted(function()
{
$this->namespaced('Modules\User\Http\Controllers', function(Router $router)
public function map(Router $router)
{
require __DIR__ . '/../Http/routes.php';
});
});
}
}
......@@ -2,7 +2,6 @@
use Illuminate\Routing\Router;
use Illuminate\Support\ServiceProvider;
use Modules\User\Events\RegisterSidebarMenuItemEvent;
class UserServiceProvider extends ServiceProvider
{
......@@ -26,6 +25,11 @@ class UserServiceProvider extends ServiceProvider
'auth.guest' => 'GuestFilter'
]
];
protected $middleware = [
'User' => [
'auth.guest' => 'GuestFilter'
]
];
/**
* Register the service provider.
......@@ -36,8 +40,8 @@ class UserServiceProvider extends ServiceProvider
{
$this->app->booted(function ($app) {
$this->registerFilters($app['router']);
$this->registerMiddleware($app['router']);
$this->registerBindings();
$this->registerEvents($app['events']);
});
}
......@@ -80,7 +84,14 @@ class UserServiceProvider extends ServiceProvider
);
}
private function registerEvents($events)
private function registerMiddleware($router)
{
foreach ($this->middleware as $module => $middlewares) {
foreach ($middlewares as $name => $middleware) {
$class = "Modules\\{$module}\\Http\\Middleware\\{$middleware}";
$router->middleware($name, $class);
}
}
}
}
......@@ -36,7 +36,7 @@ class SentinelUserRepository implements UserRepository
* @param $data
* @return mixed
*/
public function create($data)
public function create(array $data)
{
return $this->user->create((array) $data);
}
......
......@@ -14,9 +14,10 @@ interface UserRepository
/**
* Create a user resource
* @param array $data
* @return mixed
*/
public function create($data);
public function create(array $data);
/**
* Create a user and assign roles to it
......
......@@ -8,7 +8,7 @@
<?php foreach($permissionName as $permissionAction): ?>
<div class="checkbox">
<label for="<?php echo "$subPermissionTitle.$permissionAction" ?>">
<input id="<?php echo "$subPermissionTitle.$permissionAction" ?>" name="permissions[<?php echo "$subPermissionTitle.$permissionAction" ?>]" type="checkbox" class="flat-blue" <?php echo $user->hasAccess("$subPermissionTitle.$permissionAction") ? 'checked' : '' ?> value="true" /> {{ ucfirst($permissionAction) }}
<input id="<?php echo "$subPermissionTitle.$permissionAction" ?>" name="permissions[<?php echo "$subPermissionTitle.$permissionAction" ?>]" type="checkbox" class="flat-blue" <?php echo $model->hasAccess("$subPermissionTitle.$permissionAction") ? 'checked' : '' ?> value="true" /> {{ ucfirst($permissionAction) }}
</label>
</div>
<?php endforeach; ?>
......
......@@ -10,7 +10,7 @@
@stop
@section('styles')
<link href="{{{ core_asset('css/vendor/iCheck/flat/blue.css') }}}" rel="stylesheet" type="text/css" />
<link href="{{{ Module::asset('core', 'css/vendor/iCheck/flat/blue.css') }}}" rel="stylesheet" type="text/css" />
@stop
@section('content')
......@@ -47,7 +47,7 @@
</div>
</div>
<div class="tab-pane" id="tab_2-2">
@include('user::admin.roles.partials.permissions-create')
@include('user::admin.partials.permissions-create')
</div>
<div class="box-footer">
<button type="submit" class="btn btn-primary btn-flat">{{ trans('user::button.create') }}</button>
......
......@@ -12,7 +12,7 @@
@stop
@section('styles')
<link href="{{{ core_asset('css/vendor/iCheck/flat/blue.css') }}}" rel="stylesheet" type="text/css" />
<link href="{{{ Module::asset('core', 'css/vendor/iCheck/flat/blue.css') }}}" rel="stylesheet" type="text/css" />
@stop
@section('content')
......@@ -50,7 +50,7 @@
</div>
</div><!-- /.tab-pane -->
<div class="tab-pane" id="tab_2-2">
@include('user::admin.roles.partials.permissions')
@include('user::admin.partials.permissions', ['model' => $role])
</div><!-- /.tab-pane -->
<div class="tab-pane" id="tab_3-3">
<div class="box-body">
......
<div class="box-body">
<div class="row">
<div class="col-md-12">
<?php foreach($permissions as $name => $value): ?>
<h3>{{ $name }} Module</h3>
<?php foreach($value as $subPermissionTitle => $permissionName): ?>
<h4>{{ ucfirst($subPermissionTitle) }}</h4>
<?php foreach($permissionName as $permissionAction): ?>
<div class="checkbox">
<label for="<?php echo "$subPermissionTitle.$permissionAction" ?>">
<input id="<?php echo "$subPermissionTitle.$permissionAction" ?>" name="permissions[<?php echo "$subPermissionTitle.$permissionAction" ?>]" type="checkbox" class="flat-blue" value="true" /> {{ ucfirst($permissionAction) }}
</label>
</div>
<?php endforeach; ?>
<?php endforeach; ?>
<?php endforeach; ?>
</div>
</div>
</div>
\ No newline at end of file
<div class="box-body">
<div class="row">
<div class="col-md-12">
<?php foreach($permissions as $name => $value): ?>
<h3>{{ $name }} Module</h3>
<?php foreach($value as $subPermissionTitle => $permissionName): ?>
<h4>{{ ucfirst($subPermissionTitle) }}</h4>
<?php foreach($permissionName as $permissionAction): ?>
<div class="checkbox">
<label for="<?php echo "$subPermissionTitle.$permissionAction" ?>">
<input id="<?php echo "$subPermissionTitle.$permissionAction" ?>" name="permissions[<?php echo "$subPermissionTitle.$permissionAction" ?>]" type="checkbox" class="flat-blue" <?php echo $role->hasAccess("$subPermissionTitle.$permissionAction") ? 'checked' : '' ?> value="true" /> {{ ucfirst($permissionAction) }}
</label>
</div>
<?php endforeach; ?>
<?php endforeach; ?>
<?php endforeach; ?>
</div>
</div>
</div>
\ No newline at end of file
......@@ -12,7 +12,7 @@
@stop
@section('styles')
<link href="{{{ core_asset('css/vendor/iCheck/flat/blue.css') }}}" rel="stylesheet" type="text/css" />
<link href="{{{ Module::asset('core', 'css/vendor/iCheck/flat/blue.css') }}}" rel="stylesheet" type="text/css" />
@stop
@section('content')
......@@ -90,7 +90,7 @@
</div>
<div class="tab-pane" id="tab_3-3">
<div class="box-body">
@include('user::admin.users.partials.permissions-create')
@include('user::admin.partials.permissions-create')
</div>
</div>
<div class="box-footer">
......
......@@ -12,7 +12,7 @@
@stop
@section('styles')
<link href="{{{ core_asset('css/vendor/iCheck/flat/blue.css') }}}" rel="stylesheet" type="text/css" />
<link href="{{{ Module::asset('core', 'css/vendor/iCheck/flat/blue.css') }}}" rel="stylesheet" type="text/css" />
@stop
@section('content')
......@@ -72,7 +72,7 @@
</div>
<div class="tab-pane" id="tab_3-3">
<div class="box-body">
@include('user::admin.users.partials.permissions')
@include('user::admin.partials.permissions', ['model' => $user])
</div>
</div>
<div class="box-footer">
......
......@@ -9,17 +9,17 @@
</title>
<meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
<!-- bootstrap 3.0.2 -->
<link href="{{{ core_asset('css/vendor/bootstrap.min.css') }}}" rel="stylesheet" type="text/css" />
<link href="{{{ Module::asset('core', 'css/vendor/bootstrap.min.css') }}}" rel="stylesheet" type="text/css" />
<!-- font Awesome -->
<link href="{{{ core_asset('css/vendor/font-awesome.min.css') }}}" rel="stylesheet" type="text/css" />
<link href="{{{ Module::asset('core', 'css/vendor/font-awesome.min.css') }}}" rel="stylesheet" type="text/css" />
<!-- Ionicons -->
<link href="{{{ core_asset('css/vendor/ionicons.min.css') }}}" rel="stylesheet" type="text/css" />
<link href="{{{ Module::asset('core', 'css/vendor/ionicons.min.css') }}}" rel="stylesheet" type="text/css" />
<!-- Theme style -->
<link href="{{{ core_asset('css/AdminLTE.css') }}}" rel="stylesheet" type="text/css" />
<link href="{{{ core_asset('css/vendor/alertify/alertify.core.css') }}}" rel="stylesheet" type="text/css" />
<link href="{{{ core_asset('css/vendor/alertify/alertify.default.css') }}}" rel="stylesheet" type="text/css" />
<link href="{{{ Module::asset('core', 'css/AdminLTE.css') }}}" rel="stylesheet" type="text/css" />
<link href="{{{ Module::asset('core', 'css/vendor/alertify/alertify.core.css') }}}" rel="stylesheet" type="text/css" />
<link href="{{{ Module::asset('core', 'css/vendor/alertify/alertify.default.css') }}}" rel="stylesheet" type="text/css" />
<script src="{{{ core_asset('js/vendor/jquery.min.js') }}}"></script>
<script src="{{{ Module::asset('core', 'js/vendor/jquery.min.js') }}}"></script>
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
......@@ -34,7 +34,7 @@
</div>
<!-- Bootstrap -->
<script src="{{{ core_asset('js/vendor/bootstrap.min.js') }}}" type="text/javascript"></script>
<script src="{{{ core_asset('js/vendor/alertify/alertify.js') }}}" type="text/javascript"></script>
<script src="{{{ Module::asset('core', 'js/vendor/bootstrap.min.js') }}}" type="text/javascript"></script>
<script src="{{{ Module::asset('core', 'js/vendor/alertify/alertify.js') }}}" type="text/javascript"></script>
</body>
</html>
......@@ -2,38 +2,26 @@
use Cartalyst\Sentinel\Laravel\Facades\Sentinel;
use Illuminate\Support\Facades\Config;
use TestCase;
use Modules\Core\Tests\BaseTestCase;
class SessionUrlTest extends TestCase
class SessionUrlTest extends BaseTestCase
{
/** @test */
public function loginPageShouldBeAccessible()
{
$crawler = $this->client->request('GET', '/auth/login');
$this->assertTrue($this->client->getResponse()->isOk());
$this->assertCount(1, $crawler->filter('.header:contains("Sign In")'));
$this->checkResponseIsOkAndContains(['GET', '/auth/login'], '.header:contains("Sign In")');
}
/** @test */
public function registerPageShouldBeAccessible()
{
$crawler = $this->client->request('GET', '/auth/register');
$this->assertTrue($this->client->getResponse()->isOk());
$this->assertCount(1, $crawler->filter('.header:contains("Register New Membership")'));
$this->checkResponseIsOkAndContains(['GET', '/auth/register'], '.header:contains("Register New Membership")');
}
/** @test */
public function forgotPasswordShouldBeAccessible()
{
$crawler = $this->client->request('GET', '/auth/reset');
$this->assertTrue($this->client->getResponse()->isOk());
$this->assertCount(1, $crawler->filter('.header:contains("Reset Password")'));
$this->checkResponseIsOkAndContains(['GET', '/auth/reset'], '.header:contains("Reset Password")');
}
/** @test */
......@@ -42,7 +30,7 @@ class SessionUrlTest extends TestCase
$this->app['router']->enableFilters();
Sentinel::logout();
$crawler = $this->client->request('GET', '/' . Config::get('core::core.admin-prefix'));
$this->client->request('GET', '/' . Config::get('core::core.admin-prefix'));
$this->assertRedirectedTo('auth/login');
}
......@@ -56,9 +44,7 @@ class SessionUrlTest extends TestCase
$user = Sentinel::findById(4);
Sentinel::login($user);
$crawler = $this->client->request('GET', '/' . Config::get('core::core.admin-prefix'));
$this->assertTrue($this->client->getResponse()->isOk());
$this->assertCount(1, $crawler->filter('h1:contains("Dashboard")'));
$this->checkResponseIsOkAndContains(['GET', '/' . Config::get('core::core.admin-prefix')], 'h1:contains("Dashboard")');
}
}
......@@ -2,8 +2,9 @@
use Cartalyst\Sentinel\Laravel\Facades\Sentinel;
use Illuminate\Support\Facades\Config;
use Modules\Core\Tests\BaseTestCase;
class UserUrlTest extends \TestCase
class UserUrlTest extends BaseTestCase
{
public function setUp()
{
......@@ -17,11 +18,8 @@ class UserUrlTest extends \TestCase
public function userIndexShouldBeAccessible()
{
$uri = '/' . Config::get('core::core.admin-prefix') . '/users';
$crawler = $this->client->request('GET', $uri);
$this->assertTrue($this->client->getResponse()->isOk());
$this->assertCount(1, $crawler->filter('h1:contains("Users")'));
$this->checkResponseIsOkAndContains(['GET', $uri], 'h1:contains("Users")');
}
......@@ -29,54 +27,39 @@ class UserUrlTest extends \TestCase
public function userEditShouldBeAccessible()
{
$uri = '/' . Config::get('core::core.admin-prefix') . '/users/4/edit';
$crawler = $this->client->request('GET', $uri);
$this->assertTrue($this->client->getResponse()->isOk());
$this->assertCount(1, $crawler->filter('h1:contains("Edit User")'));
$this->checkResponseIsOkAndContains(['GET', $uri], 'h1:contains("Edit User")');
}
/** @test */
public function userCreateShouldBeAccessible()
{
$uri = '/' . Config::get('core::core.admin-prefix') . '/users/create';
$crawler = $this->client->request('GET', $uri);
$this->assertTrue($this->client->getResponse()->isOk());
$this->assertCount(1, $crawler->filter('h1:contains("New User")'));
$this->checkResponseIsOkAndContains(['GET', $uri], 'h1:contains("New User")');
}
/** @test */
public function roleIndexShouldBeAccessible()
{
$uri = '/' . Config::get('core::core.admin-prefix') . '/roles';
$crawler = $this->client->request('GET', $uri);
$this->assertTrue($this->client->getResponse()->isOk());
$this->assertCount(1, $crawler->filter('h1:contains("Roles")'));
$this->checkResponseIsOkAndContains(['GET', $uri], 'h1:contains("Roles")');
}
/** @test */
public function roleCreateShouldBeAccessible()
{
$uri = '/' . Config::get('core::core.admin-prefix') . '/roles/create';
$crawler = $this->client->request('GET', $uri);
$this->assertTrue($this->client->getResponse()->isOk());
$this->assertCount(1, $crawler->filter('h1:contains("New Role")'));
$this->checkResponseIsOkAndContains(['GET', $uri], 'h1:contains("New Role")');
}
/** @test */
public function roleEditShouldBeAccessible()
{
$uri = '/' . Config::get('core::core.admin-prefix') . '/roles/6/edit';
$crawler = $this->client->request('GET', $uri);
$this->assertTrue($this->client->getResponse()->isOk());
$this->assertCount(1, $crawler->filter('h1:contains("Updating Role")'));
$this->checkResponseIsOkAndContains(['GET', $uri], 'h1:contains("Updating Role")');
}
}
......@@ -3,10 +3,8 @@ use Cartalyst\Sentinel\Laravel\Facades\Sentinel;
View::composer('core::partials.sidebar-nav', 'Modules\User\Composers\SidebarViewComposer');
View::composer([
'user::admin.roles.partials.permissions',
'user::admin.roles.partials.permissions-create',
'user::admin.users.partials.permissions',
'user::admin.users.partials.permissions-create',
'user::admin.partials.permissions',
'user::admin.partials.permissions-create',
], 'Modules\User\Composers\PermissionsViewComposer');
View::composer(['core::partials.sidebar-nav', 'core::partials.top-nav'], function($view)
......
<?php
if (!function_exists('user_asset')) {
function user_asset($url, array $attributes = [], $secure = false)
{
return Module::asset('user', $url, $attributes, $secure);
}
}
\ No newline at end of file
# User module
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/304d1d01-3347-4958-915f-b2daabfe5f5a/mini.png)](https://insight.sensiolabs.com/projects/304d1d01-3347-4958-915f-b2daabfe5f5a)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/nWidart-Modules/User/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/nWidart-Modules/User/?branch=master)
This module is responsible for handling the users and roles.
## Installation
This module is loading the the [Pingpong-labs/module](https://github.com/pingpong-labs/modules) package. One way of installing it, is with the `php artisan module:install nWidart-Modules/User` command.
### Module dependencies
This module depends on the [Session module](https://github.com/nWidart-Modules/Session).
\ No newline at end of file
......@@ -18,5 +18,4 @@ Config::addNamespace('user', __DIR__ . '/Config/');
require __DIR__ . '/composers.php';
require __DIR__ . '/helpers.php';
require __DIR__ . '/listeners.php';
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment