-
Notifications
You must be signed in to change notification settings - Fork 447
Enable users without passwords to delete their accounts #9827
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
base: main
Are you sure you want to change the base?
Conversation
8a42748
to
2e58a62
Compare
schema = schemas.DeleteAccountSchema().bind(request=self.request) | ||
@property | ||
def form(self): | ||
if self._form: # pragma: no cover |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way this legacy Deform/Colander forms stuff works with instantiating schemas and then binding them to the request and then using request.create_form()
and handle_form_submission()
is just a nightmare for testability. This # pragma: no cover
here was my concession to practicality. The form has to be cached on self._form
, otherwise rendering of validation errors breaks.
|
||
def test_it_with_no_csrf_token(self, schema, pyramid_csrf_request): | ||
del pyramid_csrf_request.headers["X-CSRF-Token"] | ||
|
||
with pytest.raises(BadCSRFToken): | ||
schema.deserialize({"password": "test_password"}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this missing test for DeleteAccountSchema
.
@@ -293,6 +293,22 @@ def validator(self, node, value): | |||
raise exc | |||
|
|||
|
|||
class DeleteAccountSchemaNoPassword(CSRFSchema): | |||
username = colander.SchemaNode( | |||
colander.String(), title=_("Confirm your username to delete your account") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wondered about the phrasing here. GitHub uses "Type {text} to confirm" in its confirmation dialogs for dangerous actions, which is slightly more direct.
Testing:
devdata_user
), go to http://localhost:5000/account/delete, and you'll have to confirm your password to delete your account.