Skip to content

Commit

Permalink
Merge pull request #848 from kenjis/docs-shield-user-command
Browse files Browse the repository at this point in the history
docs: add about `shield:user` command
  • Loading branch information
datamweb authored Sep 23, 2023
2 parents 4ac3c55 + 77e2564 commit 8c4276b
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions docs/user_management/managing_users.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

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.

## Creating Users
## Managing Users by Code

### Creating Users

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.

Expand All @@ -26,7 +28,7 @@ $user = $users->findById($users->getInsertID());
$users->addToDefaultGroup($user);
```

## Deleting Users
### Deleting Users

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.

Expand All @@ -40,7 +42,7 @@ $users->delete($user->id, true);
> **Note**
> 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.
## Editing a User
### Editing a User

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.

Expand All @@ -56,3 +58,26 @@ $user->fill([
]);
$users->save($user);
```

## Managing Users via CLI

Shield has a CLI command to manage users. You can do the following actions:

```text
create: Create a new user
activate: Activate a user
deactivate: Deactivate a user
changename: Change user name
changeemail: Change user email
delete: Delete a user
password: Change a user password
list: List users
addgroup: Add a user to a group
removegroup: Remove a user from a group
```

You can get help on how to use it by running the following command in a terminal:

```console
php spark shield:user --help
```

0 comments on commit 8c4276b

Please sign in to comment.