Skip to content

Commit 8c4276b

Browse files
authored
Merge pull request #848 from kenjis/docs-shield-user-command
docs: add about `shield:user` command
2 parents 4ac3c55 + 77e2564 commit 8c4276b

1 file changed

Lines changed: 28 additions & 3 deletions

File tree

docs/user_management/managing_users.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
Since Shield uses a more complex user setup than many other systems, separating [User Identities](../getting_started/concepts.md#user-identities) from the user accounts themselves. This quick overview should help you feel more confident when working with users on a day-to-day basis.
44

5-
## Creating Users
5+
## Managing Users by Code
6+
7+
### Creating Users
68

79
By default, the only values stored in the users table is the username. The first step is to create the user record with the username. If you don't have a username, be sure to set the value to `null` anyway, so that it passes CodeIgniter's empty data check.
810

@@ -26,7 +28,7 @@ $user = $users->findById($users->getInsertID());
2628
$users->addToDefaultGroup($user);
2729
```
2830

29-
## Deleting Users
31+
### Deleting Users
3032

3133
A user's data can be spread over a few different tables so you might be concerned about how to delete all of the user's data from the system. This is handled automatically at the database level for all information that Shield knows about, through the `onCascade` settings of the table's foreign keys. You can delete a user like any other entity.
3234

@@ -40,7 +42,7 @@ $users->delete($user->id, true);
4042
> **Note**
4143
> The User rows use [soft deletes](https://codeigniter.com/user_guide/models/model.html#usesoftdeletes) so they are not actually deleted from the database unless the second parameter is `true`, like above.
4244
43-
## Editing a User
45+
### Editing a User
4446

4547
The `UserModel::save()`, `update()` and `insert()` methods have been modified to ensure that an email or password previously set on the `User` entity will be automatically updated in the correct `UserIdentity` record.
4648

@@ -56,3 +58,26 @@ $user->fill([
5658
]);
5759
$users->save($user);
5860
```
61+
62+
## Managing Users via CLI
63+
64+
Shield has a CLI command to manage users. You can do the following actions:
65+
66+
```text
67+
create: Create a new user
68+
activate: Activate a user
69+
deactivate: Deactivate a user
70+
changename: Change user name
71+
changeemail: Change user email
72+
delete: Delete a user
73+
password: Change a user password
74+
list: List users
75+
addgroup: Add a user to a group
76+
removegroup: Remove a user from a group
77+
```
78+
79+
You can get help on how to use it by running the following command in a terminal:
80+
81+
```console
82+
php spark shield:user --help
83+
```

0 commit comments

Comments
 (0)