Commit b7a4a21b authored by Nicolas Widart's avatar Nicolas Widart

Squashed 'Modules/User/' changes from 3b77eb6..9ef6f40

9ef6f40 Adding slugify option to roles
82a6a58 Removing facades and using the auth contract
8cd5b83 Implement the check method
0d53d4f Redirect to intended page
442316b Remove unused imports

git-subtree-dir: Modules/User
git-subtree-split: 9ef6f4064dbdda48d3e2e4e2ef749a9e458e9eab
parent e7005afe
<?php namespace Modules\User\Commands; <?php namespace Modules\User\Commands;
use Cartalyst\Sentinel\Laravel\Facades\Reminder;
use Cartalyst\Sentinel\Laravel\Facades\Sentinel;
use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Event;
use Laracasts\Commander\CommandHandler; use Laracasts\Commander\CommandHandler;
use Modules\User\Events\UserHasBegunResetProcess; use Modules\User\Events\UserHasBegunResetProcess;
......
<?php namespace Modules\User\Commands; <?php namespace Modules\User\Commands;
use Cartalyst\Sentinel\Laravel\Facades\Sentinel;
use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Event;
use Laracasts\Commander\CommandHandler; use Laracasts\Commander\CommandHandler;
use Modules\User\Events\UserHasRegistered; use Modules\User\Events\UserHasRegistered;
......
...@@ -42,7 +42,7 @@ class AuthController ...@@ -42,7 +42,7 @@ class AuthController
$error = $this->auth->login($credentials, $remember); $error = $this->auth->login($credentials, $remember);
if (!$error) { if (!$error) {
Flash::success('Successfully logged in.'); Flash::success('Successfully logged in.');
return Redirect::route('dashboard.index'); return Redirect::intended('/');
} }
Flash::error($error); Flash::error($error);
......
<?php namespace Modules\User\Http\Filters; <?php namespace Modules\User\Http\Filters;
use Cartalyst\Sentinel\Laravel\Facades\Sentinel; use Illuminate\Routing\Redirector;
use Illuminate\Support\Facades\Redirect; use Modules\Core\Contracts\Authentication;
class GuestFilter class GuestFilter
{ {
/**
* @var Authentication
*/
private $auth;
/**
* @var Redirector
*/
private $redirect;
public function __construct(Authentication $auth, Redirector $redirect)
{
$this->auth = $auth;
$this->redirect = $redirect;
}
public function filter() public function filter()
{ {
if (Sentinel::check()) { if ($this->auth->check()) {
return Redirect::route('dashboard.index'); return $this->redirect->route('dashboard.index');
} }
} }
} }
...@@ -116,4 +116,13 @@ class SentinelAuthentication implements Authentication ...@@ -116,4 +116,13 @@ class SentinelAuthentication implements Authentication
{ {
return Sentinel::hasAccess($permission); return Sentinel::hasAccess($permission);
} }
/**
* Check if the user is logged in
* @return mixed
*/
public function check()
{
return Sentinel::check();
}
} }
...@@ -32,14 +32,14 @@ ...@@ -32,14 +32,14 @@
<div class="col-sm-6"> <div class="col-sm-6">
<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}"> <div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
{!! Form::label('name', trans('user::roles.form.name')) !!} {!! Form::label('name', trans('user::roles.form.name')) !!}
{!! Form::text('name', Input::old('name'), ['class' => 'form-control', 'placeholder' => trans('user::roles.form.name')]) !!} {!! Form::text('name', Input::old('name'), ['class' => 'form-control slugify', 'placeholder' => trans('user::roles.form.name')]) !!}
{!! $errors->first('name', '<span class="help-block">:message</span>') !!} {!! $errors->first('name', '<span class="help-block">:message</span>') !!}
</div> </div>
</div> </div>
<div class="col-sm-6"> <div class="col-sm-6">
<div class="form-group{{ $errors->has('slug') ? ' has-error' : '' }}"> <div class="form-group{{ $errors->has('slug') ? ' has-error' : '' }}">
{!! Form::label('slug', trans('user::roles.form.slug')) !!} {!! Form::label('slug', trans('user::roles.form.slug')) !!}
{!! Form::text('slug', Input::old('slug'), ['class' => 'form-control', 'placeholder' => trans('user::roles.form.slug')]) !!} {!! Form::text('slug', Input::old('slug'), ['class' => 'form-control slug', 'placeholder' => trans('user::roles.form.slug')]) !!}
{!! $errors->first('slug', '<span class="help-block">:message</span>') !!} {!! $errors->first('slug', '<span class="help-block">:message</span>') !!}
</div> </div>
</div> </div>
......
...@@ -35,14 +35,14 @@ ...@@ -35,14 +35,14 @@
<div class="col-sm-6"> <div class="col-sm-6">
<div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}"> <div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
{!! Form::label('name', trans('user::roles.form.name')) !!} {!! Form::label('name', trans('user::roles.form.name')) !!}
{!! Form::text('name', Input::old('name', $role->name), ['class' => 'form-control', 'placeholder' => trans('user::roles.form.name')]) !!} {!! Form::text('name', Input::old('name', $role->name), ['class' => 'form-control slugify', 'placeholder' => trans('user::roles.form.name')]) !!}
{!! $errors->first('name', '<span class="help-block">:message</span>') !!} {!! $errors->first('name', '<span class="help-block">:message</span>') !!}
</div> </div>
</div> </div>
<div class="col-sm-6"> <div class="col-sm-6">
<div class="form-group{{ $errors->has('slug') ? ' has-error' : '' }}"> <div class="form-group{{ $errors->has('slug') ? ' has-error' : '' }}">
{!! Form::label('slug', trans('user::roles.form.slug')) !!} {!! Form::label('slug', trans('user::roles.form.slug')) !!}
{!! Form::text('slug', Input::old('slug', $role->slug), ['class' => 'form-control', 'placeholder' => trans('user::roles.form.slug')]) !!} {!! Form::text('slug', Input::old('slug', $role->slug), ['class' => 'form-control slug', 'placeholder' => trans('user::roles.form.slug')]) !!}
{!! $errors->first('slug', '<span class="help-block">:message</span>') !!} {!! $errors->first('slug', '<span class="help-block">:message</span>') !!}
</div> </div>
</div> </div>
......
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