Commit 283e2c13 authored by Nicolas Widart's avatar Nicolas Widart

Merge commit '6994f095'

* commit '6994f095':
  Squashed 'Modules/User/' changes from 6206740..8b9a95b
parents 668d74b9 6994f095
......@@ -8,4 +8,4 @@ class BeginResetProcessCommand
{
$this->email = $email;
}
}
\ No newline at end of file
}
......@@ -34,4 +34,4 @@ class BeginResetProcessCommandHandler implements CommandHandler
throw new UserNotFoundException();
}
}
\ No newline at end of file
}
......@@ -14,4 +14,4 @@ class CompleteResetProcessCommand
$this->userId = $userId;
$this->code = $code;
}
}
\ No newline at end of file
}
......@@ -41,4 +41,4 @@ class CompleteResetProcessCommandHandler implements CommandHandler
throw new UserNotFoundException;
}
}
\ No newline at end of file
}
......@@ -12,4 +12,4 @@ class RegisterNewUserCommand
$this->password = $password;
$this->password_confirmation = $password_confirmation;
}
}
\ No newline at end of file
}
......@@ -39,4 +39,4 @@ class RegisterNewUserCommandHandler implements CommandHandler
$group->users()->attach($user);
}
}
\ No newline at end of file
}
......@@ -19,4 +19,4 @@ class PermissionsViewComposer
// Get all permissions
$view->permissions = $this->permissions->all();
}
}
\ No newline at end of file
}
......@@ -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([
[
......@@ -29,4 +30,4 @@ class SidebarViewComposer
]
]));
}
}
\ No newline at end of file
}
......@@ -16,4 +16,4 @@ return [
'update',
'destroy'
],
];
\ No newline at end of file
];
<?php
return [
];
\ No newline at end of file
];
......@@ -66,4 +66,4 @@ class SentryGroupSeedTableSeeder extends Seeder
$group->save();
}
}
\ No newline at end of file
}
......@@ -36,4 +36,4 @@ class SentryUserSeedTableSeeder extends Seeder
$adminGroup->users()->attach($user);
}
}
\ No newline at end of file
}
......@@ -17,4 +17,4 @@ class UserDatabaseSeeder extends Seeder
$this->call("Modules\\User\\Database\\Seeders\\SentryGroupSeedTableSeeder");
}
}
\ No newline at end of file
}
......@@ -10,4 +10,4 @@ class UserHasBegunResetProcess
$this->user = $user;
$this->reminder = $reminder;
}
}
\ No newline at end of file
}
......@@ -8,4 +8,4 @@ class UserHasRegistered
{
$this->user = $user;
}
}
\ No newline at end of file
}
......@@ -5,4 +5,4 @@ use Exception;
class InvalidOrExpiredResetCode extends Exception
{
}
\ No newline at end of file
}
......@@ -5,4 +5,4 @@ use Exception;
class UserNotFoundException extends Exception
{
}
\ No newline at end of file
}
<?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');
}
}
\ No newline at end of file
}
......@@ -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);
......@@ -122,4 +117,4 @@ class UserController extends AdminBaseController
return Redirect::route('dashboard.user.index');
}
}
\ No newline at end of file
}
......@@ -35,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'));
}
......@@ -117,4 +117,4 @@ class AuthController
return Redirect::route('login');
}
}
\ No newline at end of file
}
......@@ -11,4 +11,4 @@ class GuestFilter
return Redirect::route('dashboard.index');
}
}
}
\ No newline at end of file
}
<?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
......@@ -23,4 +23,4 @@ class CreateUserRequest extends FormRequest
{
return [];
}
}
\ No newline at end of file
}
......@@ -31,4 +31,4 @@ class LoginRequest extends FormRequest
{
return [];
}
}
\ No newline at end of file
}
......@@ -31,4 +31,4 @@ class RegisterRequest extends FormRequest
{
return [];
}
}
\ No newline at end of file
}
......@@ -31,4 +31,4 @@ class ResetCompleteRequest extends FormRequest
{
return [];
}
}
\ No newline at end of file
}
......@@ -30,4 +30,4 @@ class ResetRequest extends FormRequest
{
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()
{
......@@ -21,4 +21,4 @@ class UpdateRoleRequest extends FormRequest
{
return [];
}
}
\ No newline at end of file
}
......@@ -22,4 +22,4 @@ class UpdateUserRequest extends FormRequest
{
return [];
}
}
\ No newline at end of file
}
<?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,9 +11,9 @@ 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.');
});
}
}
\ No newline at end of file
}
......@@ -19,4 +19,4 @@ class UserPresenter extends Presenter
{
return $this->first_name . ' ' . $this->last_name;
}
}
\ No newline at end of file
}
......@@ -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);
}
}
}
}
......@@ -39,4 +39,4 @@ interface RoleRepository
* @return mixed
*/
public function delete($id);
}
\ No newline at end of file
}
......@@ -69,4 +69,4 @@ class SentinelRoleRepository implements RoleRepository
return $role->delete();
}
}
\ No newline at end of file
}
......@@ -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);
}
......@@ -113,4 +113,4 @@ class SentinelUserRepository implements UserRepository
throw new UserNotFoundException;
}
}
\ No newline at end of file
}
......@@ -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
......@@ -56,4 +57,4 @@ interface UserRepository
* @return mixed
*/
public function delete($id);
}
\ No newline at end of file
}
......@@ -34,4 +34,4 @@ return [
'email' => 'Email',
'actions' => 'Actions',
]
];
\ No newline at end of file
];
......@@ -5,4 +5,4 @@ return [
'delete' => 'Suprimmer',
'create' => 'Créer',
'update' => 'Mise à jour',
];
\ No newline at end of file
];
......@@ -34,4 +34,4 @@ return [
'email' => 'Email',
'actions' => 'Actions',
]
];
\ No newline at end of file
];
......@@ -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; ?>
......@@ -16,4 +16,4 @@
<?php endforeach; ?>
</div>
</div>
</div>
\ No newline at end of file
</div>
......@@ -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">
......@@ -88,4 +88,4 @@ $( document ).ready(function() {
});
});
</script>
@stop
\ No newline at end of file
@stop
<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">
......@@ -114,4 +114,4 @@ $( document ).ready(function() {
});
});
</script>
@stop
\ No newline at end of file
@stop
......@@ -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">
......@@ -95,4 +95,4 @@ $( document ).ready(function() {
});
});
</script>
@stop
\ No newline at end of file
@stop
......@@ -105,4 +105,4 @@ background-color: #f6f6f6;
</table>
</body>
</html>
\ No newline at end of file
</html>
......@@ -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>
\ No newline at end of file
</html>
......@@ -31,4 +31,4 @@ Login | @parent
</div>
</form>
@stop
\ No newline at end of file
@stop
......@@ -29,4 +29,4 @@ Register | @parent
<a href="{{ URL::route('login') }}" class="text-center">I already have a membership</a>
</div>
{!! Form::close() !!}
@stop
\ No newline at end of file
@stop
......@@ -21,4 +21,4 @@ Reset password | @parent
</div>
{!! Form::close(); !!}
@stop
\ No newline at end of file
@stop
......@@ -25,4 +25,4 @@ Reset password | @parent
</div>
{!! Form::close(); !!}
@stop
\ No newline at end of file
@stop
......@@ -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")');
}
}
\ No newline at end of file
}
......@@ -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
<?php
Event::listen('Modules.User.Events.*', 'Modules\User\Listeners\SendResetCodeEmail');
Event::listen('Modules.User.Events.*', 'Modules\User\Listeners\SendRegistrationConfirmationEmail');
\ No newline at end of file
Event::listen('Modules.User.Events.*', 'Modules\User\Listeners\SendRegistrationConfirmationEmail');
# 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';
\ No newline at end of file
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