easyauth icon indicating copy to clipboard operation
easyauth copied to clipboard

Extend User model

Open jhonsfran opened this issue 4 years ago • 3 comments

Hi there! Thanks for the awesome work here!

I would like to know what is the best approach to extend the user's model. Should I send a PR for those changes or is there any other way to extend that model from my app?.

jhonsfran avatar Sep 15 '21 19:09 jhonsfran

Hi There @jhonsfran1165 - glad you are enjoying it so far.

Perhaps you can outline in more detail how you might like to extend the current model. If the changes make since, I would be very happy to have a PR to extend it further.

codemation avatar Sep 15 '21 21:09 codemation

Sure, I think we can add some fields:

is_active: bool = True and is_verified: bool = False

I'm using those fields to validate if the user is active and if the user was validated. I wonder if those are covered somehow in easyauth. I checked the code and I find this user model:

class User(BaseModel):  
    username: str = None  
    password: Optional[str] = None
    full_name: Optional[str] = None
    email: str = None
    groups: Union[list, dict] = None

jhonsfran avatar Sep 16 '21 00:09 jhonsfran

There is a current flow for activated users, if user activation is required i.e via sending a verification code via email.

Having a field that allows an admin to toggle on/off is a nice idea via is_active, I would only question the intent of is_verified.

Here are some other ideas / points is_active when implementing:

  • [ ] - Update model with is_active field
  • [ ] - Update Users API's to ensure field can be set / unset
  • [ ] - When a user is marked with is_active = False, we should expire / revoke tokens using this to avoid waiting for for existing tokens to expire.
  • [ ] - Optional: Translate is_active field in front_end.py to display if user is active, this code is a bit dense, so I can help here if needed.

codemation avatar Sep 16 '21 07:09 codemation