mirror of
https://github.com/getnamingo/registry.git
synced 2025-07-05 10:33:24 +02:00
Added ability to have different user statuses
This commit is contained in:
parent
33068b1356
commit
29db0ae8b6
5 changed files with 60 additions and 13 deletions
|
@ -144,6 +144,23 @@ class Auth
|
|||
|
||||
$auth->login($email, $password, $rememberDuration);
|
||||
|
||||
if ($auth->isArchived()) {
|
||||
self::$auth->logOut();
|
||||
redirect()->route('login')->with('error','User has been archived, please contact registry support');
|
||||
}
|
||||
if ($auth->isBanned()) {
|
||||
self::$auth->logOut();
|
||||
redirect()->route('login')->with('error','User has been banned, please contact registry support');
|
||||
}
|
||||
if ($auth->isPendingReview()) {
|
||||
self::$auth->logOut();
|
||||
redirect()->route('login')->with('error','User is pending review, please contact registry support');
|
||||
}
|
||||
if ($auth->isSuspended()) {
|
||||
self::$auth->logOut();
|
||||
redirect()->route('login')->with('error','User has been suspended, please contact registry support');
|
||||
}
|
||||
|
||||
// check if a valid code is provided
|
||||
global $container;
|
||||
$db = $container->get('db');
|
||||
|
|
|
@ -47,7 +47,7 @@ class UsersController extends Controller
|
|||
'username' => v::regex('/^[a-zA-Z0-9_-]+$/')->length(3, 20)->setName('Username'),
|
||||
'password' => v::stringType()->notEmpty()->length(6, 255)->setName('Password'),
|
||||
'password_confirmation' => v::equals($data['password'] ?? '')->setName('Password Confirmation'),
|
||||
'status' => v::in(['active', 'inactive'])->setName('Status'),
|
||||
'status' => v::in(['0', '4'])->setName('Status'),
|
||||
'role' => v::in(['admin', 'registrar'])->setName('Role'),
|
||||
];
|
||||
|
||||
|
@ -105,6 +105,7 @@ class UsersController extends Controller
|
|||
'username' => $username,
|
||||
'verified' => $verified,
|
||||
'roles_mask' => 6,
|
||||
'status' => $status,
|
||||
'registered' => \time()
|
||||
]
|
||||
);
|
||||
|
@ -141,6 +142,7 @@ class UsersController extends Controller
|
|||
'username' => $username,
|
||||
'verified' => $verified,
|
||||
'roles_mask' => 0,
|
||||
'status' => $status,
|
||||
'registered' => \time()
|
||||
]
|
||||
);
|
||||
|
@ -243,7 +245,7 @@ class UsersController extends Controller
|
|||
$validators = [
|
||||
'email' => v::email()->notEmpty()->setName('Email'),
|
||||
'username' => v::regex('/^[a-zA-Z0-9_-]+$/')->length(3, 20)->setName('Username'),
|
||||
'status' => v::in(['0', '1'])->setName('Status'),
|
||||
'status' => v::in(['0', '1', '2', '3', '4', '5'])->setName('Status'),
|
||||
'verified' => v::in(['0', '1'])->setName('Verified'), // Ensure verified is checked as 0 or 1
|
||||
];
|
||||
|
||||
|
|
|
@ -71,8 +71,8 @@
|
|||
<div class="mb-3">
|
||||
<label class="form-label required">{{ __('Status') }}</label>
|
||||
<select class="form-select" name="status" required>
|
||||
<option value="active">{{ __('Active') }}</option>
|
||||
<option value="inactive">{{ __('Inactive') }}</option>
|
||||
<option value="0">{{ __('Active') }}</option>
|
||||
<option value="4">{{ __('Pending Review') }}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -72,7 +72,10 @@
|
|||
<label class="form-label required">{{ __('Status') }}</label>
|
||||
<select class="form-select" name="status" required>
|
||||
<option value="0" {{ user.status == 0 ? 'selected' : '' }}>{{ __('Active') }}</option>
|
||||
<option value="1" {{ user.status == 1 ? 'selected' : '' }}>{{ __('Inactive') }}</option>
|
||||
<option value="1" {{ user.status == 1 ? 'selected' : '' }}>{{ __('Archived') }}</option>
|
||||
<option value="2" {{ user.status == 2 ? 'selected' : '' }}>{{ __('Banned') }}</option>
|
||||
<option value="4" {{ user.status == 4 ? 'selected' : '' }}>{{ __('Pending Review') }}</option>
|
||||
<option value="5" {{ user.status == 5 ? 'selected' : '' }}>{{ __('Suspended') }}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -51,12 +51,37 @@
|
|||
}
|
||||
|
||||
function statusBadgeFormatter(cell) {
|
||||
var value = cell.getValue();
|
||||
if (value === 0) {
|
||||
return '<span class="status status-green">ok</span>';
|
||||
} else {
|
||||
return '<span class="status status-red">Trouble</span>';
|
||||
const value = cell.getValue();
|
||||
let badgeClass = 'secondary';
|
||||
let statusText = 'Unknown';
|
||||
|
||||
switch (value) {
|
||||
case 0: // NORMAL
|
||||
badgeClass = 'success';
|
||||
statusText = 'Normal';
|
||||
break;
|
||||
case 1: // ARCHIVED
|
||||
badgeClass = 'dark';
|
||||
statusText = 'Archived';
|
||||
break;
|
||||
case 2: // BANNED
|
||||
badgeClass = 'danger';
|
||||
statusText = 'Banned';
|
||||
break;
|
||||
case 4: // PENDING_REVIEW
|
||||
badgeClass = 'warning';
|
||||
statusText = 'Pending Review';
|
||||
break;
|
||||
case 5: // SUSPENDED
|
||||
badgeClass = 'info';
|
||||
statusText = 'Suspended';
|
||||
break;
|
||||
default:
|
||||
badgeClass = 'secondary';
|
||||
statusText = 'Unknown';
|
||||
}
|
||||
|
||||
return `<span class="status status-${badgeClass}">${statusText}</span>`;
|
||||
}
|
||||
|
||||
var searchTerm = ""; // global variable to hold the search term
|
||||
|
@ -122,8 +147,8 @@
|
|||
{title:"{{ __('Name') }}", field:"username", width:200, resizable:false, headerSort:true, formatter: userLinkFormatter, responsive:0},
|
||||
{title:"{{ __('Email') }}", field:"email", width:300, resizable:false, headerSort:true, responsive:2},
|
||||
{title:"{{ __('Roles') }}", field:"roles_mask", width:200, resizable:false, headerSort:true, formatter: roleLabelFormatter, responsive:2},
|
||||
{title:"{{ __('Verified') }}", field:"verified", width:150, resizable:false, headerSort:true, formatter: verifiedFormatter, responsive:2},
|
||||
{title:"{{ __('Status') }}", field:"status", width:150, resizable:false, headerSort:true, formatter: statusBadgeFormatter, responsive:2},
|
||||
{title:"{{ __('Verified') }}", field:"verified", width:200, resizable:false, headerSort:true, formatter: verifiedFormatter, responsive:2},
|
||||
{title:"{{ __('Status') }}", field:"status", width:200, resizable:false, headerSort:true, formatter: statusBadgeFormatter, responsive:2},
|
||||
{title: "{{ __('Actions') }}", formatter: actionsFormatter, responsive:0, headerSort: false, download:false, hozAlign: "center", cellClick:function(e, cell){ e.stopPropagation(); }},
|
||||
]
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue