-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Spike]Make model UserProfile
more flexible
#2246
Comments
It feels to me Or maybe I am missing something ? |
Hello @jannyHou , @osmanmesutozcan I implemented the "authentication" with username and password using MongoDB where in instead of returning "UserProfile" instance (once user is Authenticated), i returned my custom class (which implements UserProfile), and it worked. Or Am i misinterpreting the question? |
@osmanmesutozcan While I also understand your concern:
The idea of turning We should explorer more approaches in this issue. |
Interesting, @rohit-khanna do you mind share your solution here? Did you also change the |
Hello @jannyHou , Custom User Profile Model
Basic Verify FunctionIt is defined inside my Invoked from
Code:
Response received at POSTMAN
|
@rohit-khanna Thanks! When you specify the type of |
@jannyHou , actually it should not complain. what do you think ? |
@rohit-khanna Looks good for me. |
@lygstate Cheers |
@jannyHou I have two comments:
In this light, I tend to agree with osmanmesutozcan who wrote
Example usage: @model()
class MyUserProfile extends Entity {
// ...
}
class MyController {
@get('/users/me', {
responses: {
'200': {
description: 'The current user profile',
content: {
'application/json': {
schema: {'x-ts-type': MyUserProfile}},
},
},
},
},
})
@authenticate('jwt')
async printCurrentUser(
@inject('authentication.currentUser') currentUser: MyUserProfile,
): Promise<MyUserProfile> {
return currentUser;
}
} I am not sure what would this mean for our implementation. Maybe we should simply change |
Discussion with @raymondfeng @jannyHou @emonddr: |
My solution is delete all properties of UserProfile interface and implement CustomUser to UserProfile. This is more flexible and easy to do. Define this interface in your project :
And change the UserProfile like this :
|
Nitpick: If we're following the Openid Standard claims would it be a good idea to rename 'id' to 'sub'? If anyone is confused, they can refer to the referenced documentation. |
@dougal83 this will be confusing for most developers. The public interface should indeed only have getters to access semantic values. A |
@jannyHou, based on what we've accomplished in the |
UserProfile
more flexibleUserProfile
more flexible
UserProfile
more flexibleUserProfile
more flexible
UserProfile
more flexibleUserProfile
more flexible
Description / Steps to reproduce / Feature proposal
See the discussion in comment, the
UserProfile
interface in@loopback/authentication
should be more flexible to allow user defined custom properties.Current Behavior
Other than the required
id
property, there are 2 optional propertiesname
andemail
, while not all the models being authenticated have them. For example, the user model hasfirstName
andsecondName
instead ofname
.Expected Behavior
Other than the required
id
property,UserProfile
should honour custom properties defined in the authenticated model.Acceptance Criteria
UserProfile
authenticate
function and the authenticated method return a user profile instance, the solution should make generating OpenAPI schema for the User model easy enough.UserProfile
into a LoopBack 4 modelUserProfile
See Reporting Issues for more tips on writing good issues
The text was updated successfully, but these errors were encountered: