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(u2f): Enable renaming u2f device #29263

Merged
merged 14 commits into from
Oct 29, 2021
Merged

feat(u2f): Enable renaming u2f device #29263

merged 14 commits into from
Oct 29, 2021

Conversation

maxiuyuan
Copy link
Contributor

@maxiuyuan maxiuyuan commented Oct 12, 2021

Allow user to rename their u2f device after being registered.

As stated in user_authenticator_details, put has been updated to rename a device's name. This put endpoint is temporary for now as we look for a new home for the parts about regenerating recover codes

https://getsentry.atlassian.net/browse/ER-641

@maxiuyuan maxiuyuan marked this pull request as draft October 12, 2021 17:36
if (id !== 'u2f' || !isEnrolled) {
return null;
}
class U2fEnrolledDetails extends React.Component<Props, State> {
Copy link
Member

Choose a reason for hiding this comment

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

Instead of making this a React.Component can we useState for any state it needs?

@maxiuyuan maxiuyuan changed the title fix(u2f): Enable renaming u2f device feat(u2f): Enable renaming u2f device Oct 13, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Oct 15, 2021

size-limit report

Path Base Size (6a417e4) Current Size Change
src/sentry/static/sentry/dist/entrypoints/app.js 52.78 KB 52.77 KB -0.01% 🔽
src/sentry/static/sentry/dist/entrypoints/sentry.css 70.9 KB 70.9 KB 0%

device["name"] = request.data.get("name")
authenticator.save()

return Response(status=status.HTTP_201_CREATED)
Copy link
Contributor

Choose a reason for hiding this comment

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

Status 201 means that we've newly created an object at a URI that the response provides. I believe 204 is correct here.

context={"authenticator": authenticator},
send_email=True,
)
return Response(serialize(interface))
Copy link
Contributor

Choose a reason for hiding this comment

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

The "if" and "else" bodies are independent modes of the endpoint. Let's extract both to their own helper methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, ill move it into their own helper methods, but I would still need to keep the if and else right? I don't want to regenerate the recovery code if i want to rename it

Copy link
Member

@leedongwei leedongwei left a comment

Choose a reason for hiding this comment

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

👍

@maxiuyuan maxiuyuan merged commit 30ba759 into master Oct 29, 2021
@maxiuyuan maxiuyuan deleted the ER-641 branch October 29, 2021 17:20
@github-actions github-actions bot locked and limited conversation to collaborators Nov 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to rename existing U2F devices
5 participants