From baf432cc61b858510dee21ec1a6791efda38fdb1 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 19 Jan 2023 09:02:47 +0900 Subject: [PATCH 1/3] docs: add empty line --- docs/concepts.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/concepts.md b/docs/concepts.md index 97ab1612b..5765c3a0f 100644 --- a/docs/concepts.md +++ b/docs/concepts.md @@ -13,6 +13,7 @@ This document covers some of the base concepts used throughout the library. Shield is designed so that the initial setup of your application can all happen in code with nothing required to be saved in the database. This means you do not have to create large seeder files that need to run within each environment. + Instead, it can be placed under version control, though the Settings library allows those settings to be easily stored in the database if you create an interface for the user to update those settings. From e2652ae310c17a11e8de7e3c01079bc3c558654e Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 19 Jan 2023 09:05:36 +0900 Subject: [PATCH 2/3] docs: move how to customize User Provider to customization.md --- docs/concepts.md | 21 +++------------------ docs/customization.md | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/docs/concepts.md b/docs/concepts.md index 5765c3a0f..6f07f4eda 100644 --- a/docs/concepts.md +++ b/docs/concepts.md @@ -25,25 +25,10 @@ on the standard Config class if nothing is found in the database. ## User Providers -You can use your own models to handle user persistence. Shield calls this the "User Provider" class. -A default model is provided for you by the `CodeIgniter\Shield\Models\UserModel` class. You can change -this in the `Config\Auth::$userProvider` setting. The only requirement is that your new class -MUST extend the provided `UserModel`. +Shield has a model to handle user persistence. Shield calls this the "User Provider" class. +A default model is provided for you by the `CodeIgniter\Shield\Models\UserModel` class. -Shield has a CLI command to quickly create a custom `UserModel` class by running the following -command in the terminal: - -```console -php spark shield:model UserModel -``` - -The class name is optional. If none is provided, the generated class name would be `UserModel`. - -You should set `Config\Auth::$userProvider` as follows: - -```php -public string $userProvider = \App\Models\UserModel::class; -``` +You can use your own model. See [Customizing Shield](./customization.md#custom-user-provider) for details. ## User Identities diff --git a/docs/customization.md b/docs/customization.md index d2f865f1c..5ccdcf6f1 100644 --- a/docs/customization.md +++ b/docs/customization.md @@ -8,6 +8,7 @@ - [Custom Validation Rules](#custom-validation-rules) - [Registration](#registration) - [Login](#login) + - [Custom User Provider](#custom-user-provider) ## Route Configuration @@ -181,3 +182,25 @@ Similar to the process for validation rules in the **Registration** section, you ], ]; ``` + +## Custom User Provider + +You can use your own "[User Provider](./concepts.md#user-providers)" class. +A default model is provided for you by the `CodeIgniter\Shield\Models\UserModel` class. You can change +this in the `Config\Auth::$userProvider` setting. The only requirement is that your new class +MUST extend the provided `UserModel`. + +Shield has a CLI command to quickly create a custom `UserModel` class by running the following +command in the terminal: + +```console +php spark shield:model UserModel +``` + +The class name is optional. If none is provided, the generated class name would be `UserModel`. + +You should set `Config\Auth::$userProvider` as follows: + +```php +public string $userProvider = \App\Models\UserModel::class; +``` From 3f4f23bf32f0cf817bf61acbc4b22c52a266d871 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 19 Jan 2023 09:26:05 +0900 Subject: [PATCH 3/3] docs: update "User Provider" explanations --- docs/concepts.md | 2 +- docs/customization.md | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/docs/concepts.md b/docs/concepts.md index 6f07f4eda..eaf57379a 100644 --- a/docs/concepts.md +++ b/docs/concepts.md @@ -28,7 +28,7 @@ on the standard Config class if nothing is found in the database. Shield has a model to handle user persistence. Shield calls this the "User Provider" class. A default model is provided for you by the `CodeIgniter\Shield\Models\UserModel` class. -You can use your own model. See [Customizing Shield](./customization.md#custom-user-provider) for details. +You can use your own model to customize user attributes. See [Customizing Shield](./customization.md#custom-user-provider) for details. ## User Identities diff --git a/docs/customization.md b/docs/customization.md index 5ccdcf6f1..7f43b6f76 100644 --- a/docs/customization.md +++ b/docs/customization.md @@ -185,10 +185,9 @@ Similar to the process for validation rules in the **Registration** section, you ## Custom User Provider -You can use your own "[User Provider](./concepts.md#user-providers)" class. -A default model is provided for you by the `CodeIgniter\Shield\Models\UserModel` class. You can change -this in the `Config\Auth::$userProvider` setting. The only requirement is that your new class -MUST extend the provided `UserModel`. +If you want to customize user attributes, you need to create your own +[User Provider](./concepts.md#user-providers) class. +The only requirement is that your new class MUST extend the provided `CodeIgniter\Shield\Models\UserModel`. Shield has a CLI command to quickly create a custom `UserModel` class by running the following command in the terminal: @@ -199,7 +198,7 @@ php spark shield:model UserModel The class name is optional. If none is provided, the generated class name would be `UserModel`. -You should set `Config\Auth::$userProvider` as follows: +After creating the class, set the `$userProvider` property in **app/Config/Auth.php** as follows: ```php public string $userProvider = \App\Models\UserModel::class;