Skip to content
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

Correct place for User type? #65

Open
SevenOutman opened this issue Mar 16, 2022 · 0 comments
Open

Correct place for User type? #65

SevenOutman opened this issue Mar 16, 2022 · 0 comments

Comments

@SevenOutman
Copy link
Contributor

Hi, I've been struggling with this confusion for some time. Here's what features I'm having in my application that is relevant to the User concept.

The auth feature

One option is to bind User type with the auth feature because without the authentication/identity logic in the application, it makes no sense of a User concept.

The admin feature

The admin feature has a user management module which may need a User type that is slightly different from the User of the auth feature. The key difference is that User in admin feature represents "others" or "the User resource", while User in auth feature represents "the current user itself". They may have slightly different properties or they can also be completely different in shape. The solution is not difficult so far. I can simply have two separate User types in those two features and perhaps name one of them AuthUser for distinction (like what happens in this demo repo).

The team feature

Here comes the problem. Now I have this third scenario of a User type where non-admin users need to query other users in the system. They query who's out there and invite them as member of their teams. Now I don't think it make sense to use AuthUser type here because this query is apparently for "the User resources", but I also don't think it make sense to import the User from admin feature because this team member function is not topologically dependent on the admin feature. I mean, I could even drop all admin features without breaking other parts of the application as a non-admin user, right?

So here's 2 options for this problem.

Option 1
Make a third User type that separates from AuthUser and User in admin feature. (Doesn't sound so good)

Option 2
Move the User from admin feature to somewhere a base User should be placed, and import it into the admin feature where its needed. AuthUser may also inherit from this base User type if compatible. (Makes more sense to me)

Either way I need to find a right place for this base User type. I'm now considering putting it in the src/types folder, or in the misc feature. Hope to hear your thoughts and suggestions.

@SevenOutman SevenOutman changed the title Correct place to place User type? Correct place for User type? Mar 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant