Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
rappasoft committed Jul 12, 2020
2 parents 8bf0dcc + 345431f commit 4907b4a
Show file tree
Hide file tree
Showing 13 changed files with 202 additions and 155 deletions.
4 changes: 2 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

# Access
ADMIN_REQUIRES_2FA=true
CHANGE_EMAIL=false
CHANGE_EMAIL=true
ENABLE_REGISTRATION=true
PASSWORD_HISTORY=3
SINGLE_LOGIN=false
PASSWORD_EXPIRES_DAYS=120
PASSWORD_EXPIRES_DAYS=180

# Captcha
# Get your credentials at: https://www.google.com/recaptcha/admin
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

## [7.1.1] - 2020-07-12

## Added

- Added method and scope to get users by type
- Added headerActions to frontend card component

## Changed

- Be explicit when showing type labels in the backend
- Moved frontend user routes to own file
- Change default password expiration days to 180
- Change default 'change email' status to true

## [7.1.0] - 2020-07-07

This release completely changes the way the previous authentication system worked. I probably went through 5 different iterations of a multi auth/guard architecture, but it became too messy and there are too many variables when dealing with different user tables and multiple different sessions. The solution I came up with I think serves the same purpose without the complexities. There is a new `type` column on the users table that is a predefined list of user types that your system supports, and a middleware to lock parts down to different types. The roles and permissions also have a corresponding `type` column to organize what roles and permissions are available to what user types, and the backend will only let you choose from the correct ones. For example: Any user of type `admin` can access the admin area, but they cannot do anything without a corresponding role or permission to a given section. This will let you structure your applications better if the use multiple different user types that have access to different areas, without using different guards, all with one users table and one login form.
Expand Down
11 changes: 11 additions & 0 deletions app/Domains/Auth/Models/Traits/Scope/UserScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,15 @@ public function scopeOnlyActive($query)
{
return $query->whereActive(true);
}

/**
* @param $query
* @param $type
*
* @return mixed
*/
public function scopeByType($query, $type)
{
return $query->where('type', $type);
}
}
15 changes: 15 additions & 0 deletions app/Domains/Auth/Services/UserService.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@ public function __construct(User $user)
$this->model = $user;
}

/**
* @param $type
* @param bool|int $perPage
*
* @return mixed
*/
public function getByType($type, $perPage = false)
{
if (is_numeric($perPage)) {
return $this->model::byType($type)->paginate($perPage);
}

return $this->model::byType($type)->get();
}

/**
* @param array $data
*
Expand Down
79 changes: 39 additions & 40 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions config/boilerplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* Whether or not a user can change their email address after
* their account has already been created
*/
'change_email' => env('CHANGE_EMAIL', false),
'change_email' => env('CHANGE_EMAIL', true),

/*
* When creating users from the backend, only allow the assigning of roles and not individual permissions
Expand All @@ -45,7 +45,7 @@
* How many days before users have to change their passwords
* false is off
*/
'password_expires_days' => env('PASSWORD_EXPIRES_DAYS', 120),
'password_expires_days' => env('PASSWORD_EXPIRES_DAYS', 180),

/*
* The number of most recent previous passwords to check against when changing/resetting a password
Expand Down
4 changes: 3 additions & 1 deletion resources/views/backend/auth/role/includes/type.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

@if ($role->type === $user::TYPE_ADMIN)
@lang('Administrator')
@else
@elseif ($role->type === $user::TYPE_USER)
@lang('User')
@else
@lang('N/A')
@endif
4 changes: 3 additions & 1 deletion resources/views/backend/auth/user/includes/type.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
@if ($user->isAdmin())
@lang('Administrator')
@else
@elseif ($user->isUser())
@lang('User')
@else
@lang('N/A')
@endif
6 changes: 6 additions & 0 deletions resources/views/components/frontend/card.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
@if (isset($header))
<div class="card-header">
{{ $header }}

@if (isset($headerActions))
<div class="d-inline-block float-right">
{{ $headerActions }}
</div><!--card-header-actions-->
@endif
</div><!--card-header-->
@endif

Expand Down
Loading

0 comments on commit 4907b4a

Please sign in to comment.