-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
25 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Spike for More Flexible UserProfile | ||
|
||
connect to story https://github.com/strongloop/loopback-next/issues/2246 | ||
|
||
I picked the `authentication-passport` module to start the spike for more flexible user profile because compared with the custom authentication strategies, users have less control to the returned user when using the passport adapter. I believe if we could find a solution for the passport based strategies, applying similar approach to a custom strategy would be easy. | ||
|
||
# Solution | ||
|
||
A converter function is introduced in the `StrategyAdapter`'s constructor module which takes in a custom user, converts it to a user profile described by `UserProfile` then return it. | ||
|
||
# Example | ||
|
||
See the corresponding change made in file 'authentication-with-passport-strategy-adapter.acceptance.ts': | ||
|
||
- Type `UserProfileInDB` is defined to describe the custom user. In a real application it should be a custom User model. | ||
- Define a converter function `converter` that turns an `UserProfileInDb` instance into a user profile. It's provided in the constructor when create the adapter. | ||
- The converter is invoked in the strategy's `authentication()` function to make sure it returns a user profile in type `UserProfile` | ||
- If the strategy is returned in a provider, you can inject the converter. | ||
|
||
# To Be Done | ||
|
||
Add a field `additionalProperties` in type `AnyObject` in the `UserProfile` interface to allow people add additional fields as the minimum set of identification info. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters