Replies: 2 comments 1 reply
-
Hi,
This is the default. Maybe I did not understand your meaning correctly.
you should implement this. |
Beta Was this translation helpful? Give feedback.
-
I understand what you want. Step1: Identify the user ID that you want to add to group php spark db:table users Data of Table "users":
+----+----------+--------+----------------+--------+-------------+--------------------+--------------------+------------+------------+-----------+--------+
| id | username | status | status_message | active | last_active | created_at | updated_at | deleted_at | first_name | last_name | avatar |
+----+----------+--------+----------------+--------+-------------+--------------------+--------------------+------------+------------+-----------+--------+
| 1 | datamweb | | | 1 | | 2022-12-18 20:1... | 2022-12-18 20:1... | | | | |
| 2 | khanumer | | | 1 | | 2022-12-19 10:2... | 2022-12-19 10:2... | | | | |
+----+----------+--------+----------------+--------+-------------+--------------------+--------------------+------------+------------+-----------+--------+ Now we want to add group Step2: add group
php spark make:seeder ShieldAddSuperAdminGroup
<?php
namespace App\Database\Seeds;
use CodeIgniter\Database\Seeder;
use CodeIgniter\I18n\Time;
class ShieldAddSuperAdminGroup extends Seeder
{
public function run()
{
$data = [
['user_id' => 2, 'group' => 'superadmin', 'created_at' => Time::now()],
];
$this->db->table('auth_groups_users')->insertBatch($data);
}
}
php spark db:seed ShieldAddSuperAdminGroup step3: limit route via group filter $routes->group('admin', ['filter' => 'group:superadmin'], static function ($routes) {
$routes->get('/admin-register', 'Admin::adminRegister');
$routes->post('/admin-register', 'Admin::adminRegister');
}); Note: Now, if the user is not in group superadmin, you will be transferred to Note: You can use the method described below to limit the viewing of the Admin panel. @khan-umer I haven't put things into practice, but it looks like it will work. Please let me know if it is the same so that other users can use it if needed. Regarding command line, currently Shield does not have a specific command for this purpose. If needed, users can submit a feature request. |
Beta Was this translation helpful? Give feedback.
-
Hello everyone,
my application requirement is to allow register only for users.
admins & other should create through backend.
I didn't found any example or docs for this kind of use cases in shield.
please share me if any helpful example for this.
Beta Was this translation helpful? Give feedback.
All reactions