Skip to content

Commit 4907b4a

Browse files
committed
Merge branch 'development'
2 parents 8bf0dcc + 345431f commit 4907b4a

File tree

13 files changed

+202
-155
lines changed

13 files changed

+202
-155
lines changed

.env.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
5959

6060
# Access
6161
ADMIN_REQUIRES_2FA=true
62-
CHANGE_EMAIL=false
62+
CHANGE_EMAIL=true
6363
ENABLE_REGISTRATION=true
6464
PASSWORD_HISTORY=3
6565
SINGLE_LOGIN=false
66-
PASSWORD_EXPIRES_DAYS=120
66+
PASSWORD_EXPIRES_DAYS=180
6767

6868
# Captcha
6969
# Get your credentials at: https://www.google.com/recaptcha/admin

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@ All notable changes to this project will be documented in this file.
33

44
## [Unreleased]
55

6+
## [7.1.1] - 2020-07-12
7+
8+
## Added
9+
10+
- Added method and scope to get users by type
11+
- Added headerActions to frontend card component
12+
13+
## Changed
14+
15+
- Be explicit when showing type labels in the backend
16+
- Moved frontend user routes to own file
17+
- Change default password expiration days to 180
18+
- Change default 'change email' status to true
19+
620
## [7.1.0] - 2020-07-07
721

822
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.

app/Domains/Auth/Models/Traits/Scope/UserScope.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,15 @@ public function scopeOnlyActive($query)
2626
{
2727
return $query->whereActive(true);
2828
}
29+
30+
/**
31+
* @param $query
32+
* @param $type
33+
*
34+
* @return mixed
35+
*/
36+
public function scopeByType($query, $type)
37+
{
38+
return $query->where('type', $type);
39+
}
2940
}

app/Domains/Auth/Services/UserService.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,21 @@ public function __construct(User $user)
3030
$this->model = $user;
3131
}
3232

33+
/**
34+
* @param $type
35+
* @param bool|int $perPage
36+
*
37+
* @return mixed
38+
*/
39+
public function getByType($type, $perPage = false)
40+
{
41+
if (is_numeric($perPage)) {
42+
return $this->model::byType($type)->paginate($perPage);
43+
}
44+
45+
return $this->model::byType($type)->get();
46+
}
47+
3348
/**
3449
* @param array $data
3550
*

composer.lock

Lines changed: 39 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/boilerplate.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
* Whether or not a user can change their email address after
3535
* their account has already been created
3636
*/
37-
'change_email' => env('CHANGE_EMAIL', false),
37+
'change_email' => env('CHANGE_EMAIL', true),
3838

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

5050
/*
5151
* The number of most recent previous passwords to check against when changing/resetting a password

resources/views/backend/auth/role/includes/type.blade.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
@if ($role->type === $user::TYPE_ADMIN)
44
@lang('Administrator')
5-
@else
5+
@elseif ($role->type === $user::TYPE_USER)
66
@lang('User')
7+
@else
8+
@lang('N/A')
79
@endif
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
@if ($user->isAdmin())
22
@lang('Administrator')
3-
@else
3+
@elseif ($user->isUser())
44
@lang('User')
5+
@else
6+
@lang('N/A')
57
@endif

resources/views/components/frontend/card.blade.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
@if (isset($header))
33
<div class="card-header">
44
{{ $header }}
5+
6+
@if (isset($headerActions))
7+
<div class="d-inline-block float-right">
8+
{{ $headerActions }}
9+
</div><!--card-header-actions-->
10+
@endif
511
</div><!--card-header-->
612
@endif
713

0 commit comments

Comments
 (0)