-
Notifications
You must be signed in to change notification settings - Fork 27
Description
@DjebbZ, All,
I have made some updates to the project, and I'm now at a crossroads, and I would like to get your input.
It seems that there is basic user information that will be required for the majority of requests. This information consists of:
- displayName
- profilePictureUrl
- isAuthenticated
- isAdmin
- roles ?
I think that there are two ways to store and access this information:
Option 1:
When the app starts make a request to {API_BASE_URL}/users/me which will return a User object for the logged in user:
{
"name": {
"givenName": "Kyle",
"familyName": "Finley"
},
"email": "test@example.com",
"password": {
"isSet": true
},
"roles": ["admin", "mod"],
"profilePictureUrl": "...",
"isAuthenticated": true,
"isAdmin": true,
// ... additional user related properties
"catsName": "Captain Whiskers",
}Pros:
- One request
- User object will be populated, so when showing extended profile information ('birthdate', 'urls', ect.) a request will not be needed.
Cons:
- The object returned will be larger then is need for most tasks.
Option 1-a:
If using option 1 -- how is the password authenticated?:
POST /auth {'email': 'test@example.com', 'password': 'pass1'}?
Option 2
When the app starts make a request to {API_BASE_URL}/sessions/me which will return a session object for the logged in user:
{
"displayName": "Kyle Finley",
"email": "test@example.com",
"password": {
"isSet": true
},
"roles": ["admin", "mod"],
"profilePictureUrl": "...",
"isAuthenticated": true,
"isAdmin": true,
// ... any additional session related data, which could be anything.
"shoppingCart": [...]
}When more detailed user information is need make a request to {API_BASE_URL}/users/me
Pros:
- Smaller initial request.
- A session (or way of storing arbitrary data) will probably be needed for other tasks anyways.
Cons:
- For more specific user information an additional request must be made E.g.
/users/me - More care must be taken to insure that information is synced between the session and the user i.e. if the user changes their
displayNameit must be updated in both theuserand thesession.
Option 2-a:
If using option 2 -- how is the password authenticated?:
POST /session {'email': 'test@example.com', 'password': 'pass1'}? Or maybe send the entire user object?
Option 3?
Thank you for your time,
Kyle