Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions app/Http/Controllers/Auth/AdminAuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use App\User as UserModal;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use User;
use Validator;

class AdminAuthController extends Controller
{
Expand Down Expand Up @@ -69,5 +67,4 @@ public function getLogout()

return redirect()->to($this->loginPath);
}

}
24 changes: 12 additions & 12 deletions app/Http/Controllers/Auth/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use User;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Validator;
use Illuminate\Http\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use User;
use Validator;

class AuthController extends Controller
{
Expand All @@ -33,19 +33,19 @@ class AuthController extends Controller
/**
* Redirect path after unsucessful attempt.
*/
protected $loginPath = 'auth/user/login';
protected $loginPath = 'auth/user/login';

/**
* Store user role.
*/
protected $role = 'user';
protected $role = 'user';

public function __construct(Request $request)
{
$this->role = $request->route('role');
$this->role = $request->route('role');
$this->middleware('guest', ['except' => 'getLogout']);
$this->loginPath = "auth/{$this->role}/login";
$this->redirectPath = $this->role;
$this->loginPath = "auth/{$this->role}/login";
$this->redirectPath = $this->role;

$this->setupTheme(config('cms.themes.user.theme'), config('cms.themes.user.layout'));
}
Expand All @@ -57,16 +57,15 @@ public function __construct(Request $request)
*/
public function getLogin(Request $request)
{
if (!User::roleExists($this->role) || $this->role == config('user.superuser_role', 'superuser')){
if (!User::roleExists($this->role) || $this->role == config('user.superuser_role', 'superuser')) {
throw new NotFoundHttpException();
}

$role = $this->role;

return $this->theme->of('public::user.login', compact('role'))->render();
}



/**
* Remove the specified resource from storage.
*
Expand All @@ -89,11 +88,12 @@ public function logout()
*/
public function getRegister(Request $request)
{
if (!User::roleExists($this->role) || $this->role == config('user.superuser_role', 'superuser') || $this->role == 'admin'){
if (!User::roleExists($this->role) || $this->role == config('user.superuser_role', 'superuser') || $this->role == 'admin') {
throw new NotFoundHttpException();
}

$role = $this->role;

return $this->theme->of('public::user.register', compact('role'))->render();
}

Expand Down Expand Up @@ -122,7 +122,7 @@ protected function validator(array $data)
*/
protected function create(array $data)
{
if (!User::roleExists($this->role) || $this->role == config('user.superuser_role', 'superuser') || $this->role == 'admin'){
if (!User::roleExists($this->role) || $this->role == config('user.superuser_role', 'superuser') || $this->role == 'admin') {
throw new NotFoundHttpException();
}

Expand Down
11 changes: 6 additions & 5 deletions app/Http/Controllers/Auth/PasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ResetsPasswords;
use Illuminate\Http\Request;
use User;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use User;

class PasswordController extends Controller
{
Expand All @@ -31,15 +31,15 @@ class PasswordController extends Controller
/**
* Store user role.
*/
protected $role = 'user';
protected $role = 'user';

/**
* Create a new password controller instance.
*/
public function __construct(Request $request)
{
$this->middleware('guest');
$this->role = $request->route('role');
$this->role = $request->route('role');
$this->redirectPath = $this->role;
$this->setupTheme(config('cms.themes.public.theme'), config('cms.themes.public.layout'));
}
Expand All @@ -51,11 +51,12 @@ public function __construct(Request $request)
*/
public function getEmail(Request $request)
{
if (!User::roleExists($this->role)){
if (!User::roleExists($this->role)) {
throw new NotFoundHttpException();
}

$role = $this->role;

return $this->theme->of('public::user.password', compact('role'))->render();
}

Expand All @@ -68,7 +69,7 @@ public function getEmail(Request $request)
*/
public function getReset($token = null)
{
if (!User::roleExists($this->role)){
if (!User::roleExists($this->role)) {
throw new NotFoundHttpException();
}

Expand Down
4 changes: 1 addition & 3 deletions app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@

class UserController extends Controller
{


public function __construct(\Illuminate\Http\Request $request)
{
$role = $request->route('role');
$role = $request->route('role');
$this->middleware('auth.role:'.$role);
$this->setupTheme(config('cms.themes.user.theme'), config('cms.themes.user.layout'));
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Middleware/RedirectIfAuthenticated.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct(Guard $auth)
*/
public function handle($request, Closure $next)
{
$role = $request->route('role');
$role = $request->route('role');
if ($this->auth->check() && $this->auth->user()->hasRole($role)) {
return redirect($role);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Middleware/RoleAuthenticate.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ public function handle($request, Closure $next, $role)
return redirect()->guest("auth/$role/login");
}
}
}
}
28 changes: 14 additions & 14 deletions app/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

namespace App;

use Lavalite\Filer\FilerTrait;
use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Foundation\Auth\Access\Authorizable;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\Access\Authorizable;
use Lavalite\Filer\FilerTrait;
use Lavalite\User\Traits\CheckPermission;
use URL;

Expand Down Expand Up @@ -39,11 +38,11 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
*/
protected $casts = [
'photo' => 'array',
'permissions' => 'array'
'permissions' => 'array',
];

/**
* Initialiaze page modal
* Initialiaze page modal.
*
* @param $name
*/
Expand All @@ -60,13 +59,12 @@ public function __construct()
*/
public function initialize()
{
$this->fillable = config('user.user.fillable');
$this->uploads = config('user.user.uploadable');
$this->uploadRootFolder = config('user.user.upload_root_folder');
$this->table = config('user.user.table');
$this->fillable = config('user.user.fillable');
$this->uploads = config('user.user.uploadable');
$this->uploadRootFolder = config('user.user.upload_root_folder');
$this->table = config('user.user.table');
}


/**
* Returns the profile picture of the user.
*
Expand All @@ -76,11 +74,13 @@ public function getPictureAttribute($value)
{
if (!empty($value)) {
$photo = json_encode($value);
return URL::to($photo['folder'] . '/' . $photo['file']);

return URL::to($photo['folder'].'/'.$photo['file']);
}

if ($this->sex == 'Female')
if ($this->sex == 'Female') {
return URL::to('images/avatar/female.png');
}

return URL::to('images/avatar/male.png');
}
Expand Down
57 changes: 26 additions & 31 deletions config/package/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,67 +2,63 @@

return [

/**
/*
* Provider .
*/

'provider' => 'lavalite',

/**
/*
* package .
*/

'package' => 'user',

'modules' => ['user', 'role', 'permission'],

'permission' =>
[
'permission' => [
'Name' => 'Permission',
'name' => 'permission',
'table' => 'permissions',
'model' => 'Lavalite\User\Models\Permission',
'permissions' => ['view', 'create', 'edit', 'delete'],
'image' =>
[
'xs' => ['width' => '60', 'height' =>'45'],
'sm' => ['width' => '100', 'height' =>'75'],
'md' => ['width' => '460', 'height' =>'345'],
'lg' => ['width' => '800', 'height' =>'600'],
'xl' => ['width' => '1000', 'height' =>'750'],
'image' => [
'xs' => ['width' => '60', 'height' => '45'],
'sm' => ['width' => '100', 'height' => '75'],
'md' => ['width' => '460', 'height' => '345'],
'lg' => ['width' => '800', 'height' => '600'],
'xl' => ['width' => '1000', 'height' => '750'],
],
'fillable' => ['id', 'name', 'readable_name', 'created_at', 'updated_at'],
'listfields' => ['id', 'name', 'readable_name', 'created_at', 'updated_at'],
'translatable' => ['id', 'name', 'readable_name', 'created_at', 'updated_at'],
'upload-folder' => '/uploads/permissions',
'uploadable' => [
'single' => [],
'multiple' => []
'multiple' => [],
],

],
'role' =>
[
'role' => [
'Name' => 'Role',
'name' => 'role',
'table' => 'roles',
'model' => 'Lavalite\User\Models\Role',
'permissions' => ['view', 'create', 'edit', 'delete'],
'image' =>
[
'xs' => ['width' => '60', 'height' =>'45'],
'sm' => ['width' => '100', 'height' =>'75'],
'md' => ['width' => '460', 'height' =>'345'],
'lg' => ['width' => '800', 'height' =>'600'],
'xl' => ['width' => '1000', 'height' =>'750'],
'image' => [
'xs' => ['width' => '60', 'height' => '45'],
'sm' => ['width' => '100', 'height' => '75'],
'md' => ['width' => '460', 'height' => '345'],
'lg' => ['width' => '800', 'height' => '600'],
'xl' => ['width' => '1000', 'height' => '750'],
],
'fillable' => ['id', 'name', 'created_at', 'updated_at'],
'listfields' => ['id', 'name', 'created_at', 'updated_at'],
'translatable' => ['id', 'name', 'created_at', 'updated_at'],
'upload-folder' => '/uploads/roles',
'uploadable' => [
'single' => [],
'multiple' => []
'multiple' => [],
],

],
Expand All @@ -73,22 +69,21 @@
'table' => 'users',
'model' => 'Lavalite\User\Models\User',
'permissions' => ['view', 'create', 'edit', 'delete'],
'image' =>
[
'xs' => ['width' => '60', 'height' =>'45'],
'sm' => ['width' => '100', 'height' =>'75'],
'md' => ['width' => '460', 'height' =>'345'],
'lg' => ['width' => '800', 'height' =>'600'],
'xl' => ['width' => '1000', 'height' =>'750'],
'image' => [
'xs' => ['width' => '60', 'height' => '45'],
'sm' => ['width' => '100', 'height' => '75'],
'md' => ['width' => '460', 'height' => '345'],
'lg' => ['width' => '800', 'height' => '600'],
'xl' => ['width' => '1000', 'height' => '750'],
],
'fillable' => ['id', 'reporting_to', 'name', 'email', 'password', 'active', 'remember_token', 'sex', 'dob',
'designation', 'mobile', 'phone', 'address', 'street', 'city', 'district', 'state', 'country', 'web'],
'designation', 'mobile', 'phone', 'address', 'street', 'city', 'district', 'state', 'country', 'web', ],
'listfields' => ['id', 'reporting_to', 'name', 'email', 'password', 'active', 'remember_token', 'sex', 'dob', 'designation', 'mobile', 'phone', 'address', 'street', 'city', 'district', 'state', 'country', 'web', 'social_login', 'deleted_at', 'created_at', 'updated_at'],
'translatable' => ['id', 'reporting_to', 'name', 'email', 'password', 'active', 'remember_token', 'sex', 'dob', 'designation', 'mobile', 'phone', 'address', 'street', 'city', 'district', 'state', 'country', 'web', 'social_login', 'deleted_at', 'created_at', 'updated_at'],
'upload-folder' => '/uploads/users',
'uploadable' => [
'single' => ['photo'],
'multiple' => []
'multiple' => [],
],

],
Expand Down