Skip to content

Commit

Permalink
Merge pull request #22 from ARCANESOFT/develop
Browse files Browse the repository at this point in the history
Updating the laravel-auth package
  • Loading branch information
arcanedev-maroc authored Jul 31, 2017
2 parents 062bf2c + 9807d58 commit f7b08d5
Show file tree
Hide file tree
Showing 15 changed files with 129 additions and 95 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"require": {
"php": ">=5.6.4",
"arcanedev/gravatar": "~2.0",
"arcanedev/laravel-auth": "~2.2",
"arcanedev/laravel-auth": "~3.0",
"arcanedev/laravel-impersonator": "^1.1",
"arcanesoft/core": "~2.4"
},
Expand Down
131 changes: 113 additions & 18 deletions config/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,59 +48,154 @@

'users' => [
'table' => 'users',
'model' => \Arcanesoft\Auth\Models\User::class,
'observer' => \Arcanesoft\Auth\Models\Observers\UserObserver::class,
'model' => Arcanesoft\Auth\Models\User::class,
'slug-separator' => '.',
],

'roles' => [
'table' => 'roles',
'model' => \Arcanesoft\Auth\Models\Role::class,
'observer' => \Arcanesoft\Auth\Models\Observers\RoleObserver::class,
'model' => Arcanesoft\Auth\Models\Role::class,
'slug-separator' => '-',
],

'role-user' => [
'table' => 'role_user',
'model' => \Arcanedev\LaravelAuth\Models\Pivots\RoleUser::class,
'model' => Arcanedev\LaravelAuth\Models\Pivots\RoleUser::class,
],

'permissions-groups' => [
'table' => 'permissions_groups',
'model' => \Arcanesoft\Auth\Models\PermissionsGroup::class,
'observer' => \Arcanesoft\Auth\Models\Observers\PermissionsGroupObserver::class,
'model' => Arcanesoft\Auth\Models\PermissionsGroup::class,
'slug-separator' => '-',
],

'permissions' => [
'table' => 'permissions',
'model' => \Arcanesoft\Auth\Models\Permission::class,
'observer' => \Arcanesoft\Auth\Models\Observers\PermissionObserver::class,
'model' => Arcanesoft\Auth\Models\Permission::class,
'slug-separator' => '.',
],

'permission-role' => [
'table' => 'permission_role',
'model' => \Arcanedev\LaravelAuth\Models\Pivots\PermissionRole::class,
'model' => Arcanedev\LaravelAuth\Models\Pivots\PermissionRole::class,
],

'password-resets' => [
'model' => \Arcanedev\LaravelAuth\Models\PasswordReset::class,
'model' => Arcanedev\LaravelAuth\Models\PasswordReset::class,
],

/* -----------------------------------------------------------------
| Observers
| Events & Listeners
| -----------------------------------------------------------------
*/

'observers' => [
'events' => [
'enabled' => true,

'bindings' => [
'users' => \Arcanesoft\Contracts\Auth\Models\User::class,
'roles' => \Arcanesoft\Contracts\Auth\Models\Role::class,
'permissions-groups' => \Arcanesoft\Contracts\Auth\Models\PermissionsGroup::class,
'permissions' => \Arcanesoft\Contracts\Auth\Models\Permission::class,
'listeners' => [
// User Model events & listeners
//-----------------------------------------------------
// Eloquent events
Arcanedev\LaravelAuth\Events\Users\CreatingUser::class => [
Arcanedev\LaravelAuth\Listeners\Users\GenerateConfirmationCode::class,
],
Arcanedev\LaravelAuth\Events\Users\CreatedUser::class => [],
Arcanedev\LaravelAuth\Events\Users\UpdatingUser::class => [],
Arcanedev\LaravelAuth\Events\Users\UpdatedUser::class => [],
Arcanedev\LaravelAuth\Events\Users\SavingUser::class => [],
Arcanedev\LaravelAuth\Events\Users\SavedUser::class => [],
Arcanedev\LaravelAuth\Events\Users\DeletingUser::class => [
Arcanedev\LaravelAuth\Listeners\Users\DetachingRoles::class,
],
Arcanedev\LaravelAuth\Events\Users\DeletedUser::class => [],
Arcanedev\LaravelAuth\Events\Users\RestoringUser::class => [],
Arcanedev\LaravelAuth\Events\Users\RestoredUser::class => [],
// Custom events
Arcanedev\LaravelAuth\Events\Users\ActivatingUser::class => [],
Arcanedev\LaravelAuth\Events\Users\ActivatedUser::class => [],
Arcanedev\LaravelAuth\Events\Users\DeactivatingUser::class => [],
Arcanedev\LaravelAuth\Events\Users\DeactivatedUser::class => [],
Arcanedev\LaravelAuth\Events\Users\AttachingRoleToUser::class => [],
Arcanedev\LaravelAuth\Events\Users\AttachedRoleToUser::class => [],
Arcanedev\LaravelAuth\Events\Users\SyncingUserWithRoles::class => [],
Arcanedev\LaravelAuth\Events\Users\SyncedUserWithRoles::class => [],
Arcanedev\LaravelAuth\Events\Users\DetachingRoleFromUser::class => [],
Arcanedev\LaravelAuth\Events\Users\DetachedRoleFromUser::class => [],
Arcanedev\LaravelAuth\Events\Users\DetachingRolesFromUser::class => [],
Arcanedev\LaravelAuth\Events\Users\DetachedRolesFromUser::class => [],

// Role Model events & listeners
//-----------------------------------------------------
Arcanedev\LaravelAuth\Events\Roles\CreatingRole::class => [],
Arcanedev\LaravelAuth\Events\Roles\CreatedRole::class => [],
Arcanedev\LaravelAuth\Events\Roles\UpdatingRole::class => [],
Arcanedev\LaravelAuth\Events\Roles\UpdatedRole::class => [],
Arcanedev\LaravelAuth\Events\Roles\SavingRole::class => [],
Arcanedev\LaravelAuth\Events\Roles\SavedRole::class => [],
Arcanedev\LaravelAuth\Events\Roles\DeletingRole::class => [
Arcanedev\LaravelAuth\Listeners\Roles\DetachingUsers::class,
Arcanedev\LaravelAuth\Listeners\Roles\DetachingPermissions::class,
],
Arcanedev\LaravelAuth\Events\Roles\DeletedRole::class => [],
// Custom
Arcanedev\LaravelAuth\Events\Roles\AttachingUserToRole::class => [],
Arcanedev\LaravelAuth\Events\Roles\AttachedUserToRole::class => [],
Arcanedev\LaravelAuth\Events\Roles\DetachingUserFromRole::class => [],
Arcanedev\LaravelAuth\Events\Roles\DetachedUserFromRole::class => [],
Arcanedev\LaravelAuth\Events\Roles\DetachingAllUsersFromRole::class => [],
Arcanedev\LaravelAuth\Events\Roles\DetachedAllUsersFromRole::class => [],
Arcanedev\LaravelAuth\Events\Roles\AttachingPermissionToRole::class => [],
Arcanedev\LaravelAuth\Events\Roles\AttachedPermissionToRole::class => [],
Arcanedev\LaravelAuth\Events\Roles\DetachingPermissionFromRole::class => [],
Arcanedev\LaravelAuth\Events\Roles\DetachedPermissionFromRole::class => [],
Arcanedev\LaravelAuth\Events\Roles\DetachingAllPermissionsFromRole::class => [],
Arcanedev\LaravelAuth\Events\Roles\DetachedAllPermissionsFromRole::class => [],

// Permission Model events & listeners
//-----------------------------------------------------
Arcanedev\LaravelAuth\Events\Permissions\CreatingPermission::class => [],
Arcanedev\LaravelAuth\Events\Permissions\CreatedPermission::class => [],
Arcanedev\LaravelAuth\Events\Permissions\UpdatingPermission::class => [],
Arcanedev\LaravelAuth\Events\Permissions\UpdatedPermission::class => [],
Arcanedev\LaravelAuth\Events\Permissions\SavingPermission::class => [],
Arcanedev\LaravelAuth\Events\Permissions\SavedPermission::class => [],
Arcanedev\LaravelAuth\Events\Permissions\DeletingPermission::class => [
Arcanedev\LaravelAuth\Listeners\Permissions\DetachingRoles::class,
],
Arcanedev\LaravelAuth\Events\Permissions\DeletedPermission::class => [],
// Custom
Arcanedev\LaravelAuth\Events\Permissions\AttachingRoleToPermission::class => [],
Arcanedev\LaravelAuth\Events\Permissions\AttachedRoleToPermission::class => [],
Arcanedev\LaravelAuth\Events\Permissions\DetachingRoleFromPermission::class => [],
Arcanedev\LaravelAuth\Events\Permissions\DetachedRoleFromPermission::class => [],
Arcanedev\LaravelAuth\Events\Permissions\DetachingAllRolesFromPermission::class => [],
Arcanedev\LaravelAuth\Events\Permissions\DetachedAllRolesFromPermission::class => [],
Arcanedev\LaravelAuth\Events\Permissions\SyncingRolesWithPermission::class => [],
Arcanedev\LaravelAuth\Events\Permissions\SyncedRolesWithPermission::class => [],

// Permission's Group Model events & listeners
//-----------------------------------------------------
Arcanedev\LaravelAuth\Events\PermissionsGroups\CreatingPermissionsGroup::class => [],
Arcanedev\LaravelAuth\Events\PermissionsGroups\CreatedPermissionsGroup::class => [],
Arcanedev\LaravelAuth\Events\PermissionsGroups\UpdatingPermissionsGroup::class => [],
Arcanedev\LaravelAuth\Events\PermissionsGroups\UpdatedPermissionsGroup::class => [],
Arcanedev\LaravelAuth\Events\PermissionsGroups\SavingPermissionsGroup::class => [],
Arcanedev\LaravelAuth\Events\PermissionsGroups\SavedPermissionsGroup::class => [],
Arcanedev\LaravelAuth\Events\PermissionsGroups\DeletingPermissionsGroup::class => [
Arcanedev\LaravelAuth\Listeners\PermissionGroups\DetachingPermissions::class,
],
Arcanedev\LaravelAuth\Events\PermissionsGroups\DeletedPermissionsGroup::class => [],
// Custom
Arcanedev\LaravelAuth\Events\PermissionsGroups\AttachingPermissionToGroup::class => [],
Arcanedev\LaravelAuth\Events\PermissionsGroups\AttachedPermissionToGroup::class => [],
Arcanedev\LaravelAuth\Events\PermissionsGroups\AttachingPermissionsToGroup::class => [],
Arcanedev\LaravelAuth\Events\PermissionsGroups\AttachedPermissionsToGroup::class => [],
Arcanedev\LaravelAuth\Events\PermissionsGroups\DetachingPermissionFromGroup::class => [],
Arcanedev\LaravelAuth\Events\PermissionsGroups\DetachedPermissionFromGroup::class => [],
Arcanedev\LaravelAuth\Events\PermissionsGroups\DetachingPermissionsFromGroup::class => [],
Arcanedev\LaravelAuth\Events\PermissionsGroups\DetachedPermissionsFromGroup::class => [],
Arcanedev\LaravelAuth\Events\PermissionsGroups\DetachingAllPermissions::class => [],
Arcanedev\LaravelAuth\Events\PermissionsGroups\DetachedAllPermissions::class => [],
],
],

Expand Down
1 change: 0 additions & 1 deletion src/AuthServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public function register()
Providers\AuthorizationServiceProvider::class,
Providers\ViewComposerServiceProvider::class,
Providers\ValidatorServiceProvider::class,
Providers\EventServiceProvider::class,
Providers\RouteServiceProvider::class,
]);
$this->registerConsoleServiceProvider(Providers\CommandServiceProvider::class);
Expand Down
14 changes: 0 additions & 14 deletions src/Models/Observers/PermissionObserver.php

This file was deleted.

14 changes: 0 additions & 14 deletions src/Models/Observers/PermissionsGroupObserver.php

This file was deleted.

14 changes: 0 additions & 14 deletions src/Models/Observers/RoleObserver.php

This file was deleted.

14 changes: 0 additions & 14 deletions src/Models/Observers/UserObserver.php

This file was deleted.

6 changes: 3 additions & 3 deletions src/Models/Permission.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ public static function firstHashedOrFail($hashedId)
/**
* Get the ids of all permissions.
*
* @return \Illuminate\Database\Eloquent\Collection
* @return \Illuminate\Support\Collection
*/
public static function getIds()
{
return self::orderBy('id')->pluck('id');
return self::query()->orderBy('id')->pluck('id');
}

/* -----------------------------------------------------------------
Expand All @@ -58,6 +58,6 @@ public static function getIds()
*/
public function hasGroup()
{
return $this->group_id !== 0;
return $this->group_id > 0;
}
}
3 changes: 3 additions & 0 deletions src/Models/Presenters/HasherTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ trait HasherTrait
| Scopes
| -----------------------------------------------------------------
*/

/**
* Scope with the hashed id.
*
Expand All @@ -36,6 +37,7 @@ public function scopeWithHashedId(Builder $query, $hashedId)
| Getters & Setters
| -----------------------------------------------------------------
*/

/**
* Get the model hash id.
*
Expand All @@ -50,6 +52,7 @@ public function getHashedIdAttribute()
| Other Methods
| -----------------------------------------------------------------
*/

/**
* Get the hasher.
*
Expand Down
1 change: 1 addition & 0 deletions src/Models/Presenters/PermissionPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ trait PermissionPresenter
| Traits
| -----------------------------------------------------------------
*/

use HasherTrait;
}
1 change: 1 addition & 0 deletions src/Models/Presenters/PermissionsGroupPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ trait PermissionsGroupPresenter
| Traits
| -----------------------------------------------------------------
*/

use HasherTrait;
}
1 change: 1 addition & 0 deletions src/Models/Presenters/RolePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ trait RolePresenter
| Traits
| -----------------------------------------------------------------
*/

use HasherTrait;
}
2 changes: 2 additions & 0 deletions src/Models/Presenters/UserPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ trait UserPresenter
| Traits
| -----------------------------------------------------------------
*/

use HasherTrait;

/* -----------------------------------------------------------------
| Getters & Setters
| -----------------------------------------------------------------
*/

/**
* Get the `full_name` attribute or use the username if empty.
*
Expand Down
14 changes: 0 additions & 14 deletions src/Providers/EventServiceProvider.php

This file was deleted.

6 changes: 4 additions & 2 deletions src/Providers/PackagesServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,13 @@ private function registerLaravelImpersonatorPackage()
*/
private function configLaravelAuthPackage()
{
/** @var \Illuminate\Contracts\Config\Repository $config */
$config = $this->config();
$config->set(
'laravel-auth',
Arr::except($config->get('arcanesoft.auth'), ['route', 'hasher', 'impersonation'])
Arr::only($config->get('arcanesoft.auth'), [
'database', 'users', 'roles', 'role-user', 'permissions-groups', 'permissions', 'permission-role',
'password-resets', 'events', 'user-confirmation', 'track-activity', 'socialite', 'throttles', 'seeds'
])
);

if (SocialAuthenticator::isEnabled()) {
Expand Down

0 comments on commit f7b08d5

Please sign in to comment.