-
Notifications
You must be signed in to change notification settings - Fork 17
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
Add email password sign in to dashboard #55
Comments
MVP version
V2:
V3:
|
TerminologyDashboard Users: User's that are allowed to use the dashboard via email password login. These users are completely independent of the rest of the system and are only relevant to the dashboard. General flowFrontend -> Backend
Backend -> Core
Core
Summary of changesBackend SDK1.
|
id | is_suspended | time_joined | password_hash | |
---|---|---|---|---|
uid (primary) | string (unique) | bool | number | string |
General Notes
-
When creating users check if the feature flag for dashboard is enabled, If yes continue. If no check if the total number of users in the table (suspended or otherwise) is greater than or equal to 2. If more than 2 then the operation should not be allowed
-
During sign in if the feature flag is not enabled, check if the user is suspended and block the operation if they are.
-
All operations first call a common function. This function will check if the feature flag is enabled, if it isnt then mark all users other than the oldest 2 users in the table (based on time_joined) as suspended. If it is enabled then mark users in the table as not suspended
API Changes
ALL APIS REQUIRE AN API KEY
ALL APIS REQUIRE AN API KEY
ALL APIS REQUIRE AN API KEY
/recipe/dashboard/user POST
- Used to create new dashboard users
This API should check if a user should be allowed to be created before proceeding with its logic (as explained in the general notes section)
The email should have a basic regex string validation. The password can have a medium strength regex.
Request:
email: string,
password: string,
Response:
| {status: "OK"}
| {status: "EMAIL_ALREADY_EXISTS_ERROR"}
| {status: "INVALID_EMAIL_ERROR"}
| {status: "PASSWORD_WEAK_ERROR"}
|
|
|
HTTP Status Code: 402
{status: "USER_LIMIT_REACHED_ERROR"}
/recipe/dashboard/user PUT
- Used to edit the user's email or password
The same validation that happen in the POST API should apply here as well.
Request:
{
email: string,
newPassword?: string,
newEmail?: string,
} | {
userId: string,
newPassword?: string,
newEmail?: string,
}
This API should be a no-op if both newEmail
and newPassword
are missing. If both email
and userId
are present, the priority should be userId
and the API should fail without trying with the email
Removed
{status: "USER_LIMIT_REACHED_ERROR"}
Response:
| {status: "OK"}
| {status: "EMAIL_ALREADY_EXISTS_ERROR"}
| {status: "INVALID_EMAIL_ERROR"}
| {status: "PASSWORD_WEAK_ERROR"}
/recipe/dashboard/users GET
- Used to get a list of all dashboard users
Request: {}
Response:
{
users: {
email: string,
userId: string,
isSuspended: bool,
}[]
}
/recipe/dashboard/user DELETE
- used to delete a specific user
Request:
| { userId: string}
| { email: string }
If both email
and userId
are present, the priority should be userId
and the API should fail without trying with the email
Response:
{
status: "OK",
didUserExist: bool,
}
/recipe/dashboard/jwt/verify POST
- Used to verify the JWT header sent by the frontend
This API needs to verify the JWT against the signing key for the dashboard recipe and not the JWT recipe (explained in the general notes). When verifying the JWT, ignore the expiry of the JWT (or set a really long expiry when creating it)
Verification involves a couple steps:
- Verify the JWT with normal JWT verification
- From the payload read the
userId
- Check if a user with that
userId
is present and not suspended. If the user is not present or the user is suspended, the API should return an error status
Request:
{ sessionID: string }
Response:
| {status: "OK"}
| {status: "USER_SUSPENDED_ERROR"}
| {status: "INVALID_SESSION"}
/recipe/dashboard/signin POST
- Used to sign in users and issue a JWT
Request:
{
email: string,
password: string,
}
Response:
| {status: "OK", sessionId: string}
| {status: "INVALID_CREDENTIALS_ERROR"}
| {status: "USER_SUSPENDED_ERROR"}
@jscyo @AreebKhan619 review when you can ^ |
The dashbaord_emailpassword_users schema will not have the |
New Changes
@nkshah2 @AreebKhan619 The API spec will need to be updated for this |
@jscyo @AreebKhan619 Ive updated the spec, summary of changes: On the backend SDKs:
Core
|
Errors that require message for additional context
|
/user PUT API should clear all current sessions of the user if the email or password or both have been modified |
New core APIs:
New APIs in backend SDK
Auth method change in backend SDK
Verify the JWT and then query the core to check if the user exists or not.
Frontend change
The text was updated successfully, but these errors were encountered: