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

feat: add mobile login handler #1207

Merged
merged 5 commits into from
Nov 11, 2024
Merged

feat: add mobile login handler #1207

merged 5 commits into from
Nov 11, 2024

Conversation

vnugent
Copy link
Contributor

@vnugent vnugent commented Nov 9, 2024

What type of PR is this?(check all applicable)

  • refactor
  • feature
  • bug fix
  • documentation
  • optimization
  • other

What this PR achieves

  • Private API for mobile authentication (via Auth0 sdk)
    /api/mobile/login
    /api/mobile/refreshToken
    
  • Upgrade Auth0 lib
  • Fix unrelated user mgmt code breaks due to Auth0 lib upgrade
  • Remove dead code
  • Unit test in a follow up PR

@vnugent
Copy link
Contributor Author

vnugent commented Nov 11, 2024

FYI @clintonlunn
Most important changes in this PR:

@@ -30,7 +30,7 @@
"@turf/line-to-polygon": "^6.5.0",
"@udecode/zustood": "^1.1.3",
"@vercel/edge": "^1.1.1",
"auth0": "^2.42.0",
"auth0": "^4.12.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jumping from v2 -> v4 broke a lot of user management code

if (roleObj.name != null && roleObj.id != null && !roles.includes(roleObj.name)) {
res.push(roleObj.id)
}
return res
}, [])
// Removes roles that the user doesn't even have, but that's ok.
if (roleIdsToRemove.length > 0) await auth0ManagementClient.removeRolesFromUser({ id: userId }, { roles: roleIdsToRemove })
if (roleIdsToRemove.length > 0) await auth0ManagementClient.users.deleteRoles({ id: userId }, { roles: roleIdsToRemove })
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the intent of this to delete roles from the user or delete the role from auth0 all together? it seems the original intent was to just remove a role from a user. (not familiar with this so i can be off in my assumptions)

actually since you're specifying users you're probably deleting from the user itself, not the entire role

username,
password,
scope: 'openid profile email offline_access',
audience: 'https://api.openbeta.io'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be generalized to whatever the current environment is?

Copy link
Contributor Author

@vnugent vnugent Nov 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The settings are identical for both dev/stg and prod.

try {
response = await auth0Client.oauth.refreshTokenGrant({
refresh_token: refreshToken,
audience: 'https://api.openbeta.io'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as above

@vnugent vnugent merged commit bf4c61f into develop Nov 11, 2024
4 of 8 checks passed
@vnugent vnugent deleted the mobile-auth branch November 11, 2024 17:10
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

Successfully merging this pull request may close these issues.

2 participants