diff --git a/cp/app/Auth/Auth.php b/cp/app/Auth/Auth.php index 93f9b4a..8034e60 100644 --- a/cp/app/Auth/Auth.php +++ b/cp/app/Auth/Auth.php @@ -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'); diff --git a/cp/app/Controllers/UsersController.php b/cp/app/Controllers/UsersController.php index 5661ab1..4046c49 100644 --- a/cp/app/Controllers/UsersController.php +++ b/cp/app/Controllers/UsersController.php @@ -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 ]; diff --git a/cp/resources/views/admin/users/createUser.twig b/cp/resources/views/admin/users/createUser.twig index b06f5e6..339913a 100644 --- a/cp/resources/views/admin/users/createUser.twig +++ b/cp/resources/views/admin/users/createUser.twig @@ -71,8 +71,8 @@
diff --git a/cp/resources/views/admin/users/updateUser.twig b/cp/resources/views/admin/users/updateUser.twig index cbf525e..59354de 100644 --- a/cp/resources/views/admin/users/updateUser.twig +++ b/cp/resources/views/admin/users/updateUser.twig @@ -72,11 +72,14 @@ - +
diff --git a/cp/resources/views/partials/js-users.twig b/cp/resources/views/partials/js-users.twig index fac6a55..ca5b236 100644 --- a/cp/resources/views/partials/js-users.twig +++ b/cp/resources/views/partials/js-users.twig @@ -51,12 +51,37 @@ } function statusBadgeFormatter(cell) { - var value = cell.getValue(); - if (value === 0) { - return 'ok'; - } else { - return 'Trouble'; + 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 `${statusText}`; } 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(); }}, ] });