Skip to content

Commit

Permalink
feat: Allow users to delete their own accounts (#8548)
Browse files Browse the repository at this point in the history
* Allow users to delete their own accounts

* Change to using a button for delete
  • Loading branch information
john-gom committed Jun 15, 2023
1 parent 2dee723 commit 6a294d0
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
7 changes: 1 addition & 6 deletions cgi/user.pl
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,7 @@

if ($type eq 'edit') {
if (single_param('delete') eq 'on') {
if ($admin) {
$type = 'delete';
}
else {
display_error_and_exit($Lang{error_no_permission}{$lang}, 403);
}
$type = 'delete';
}
}

Expand Down
10 changes: 9 additions & 1 deletion po/common/common.pot
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,15 @@ msgid "Delete the images"
msgstr ""

msgctxt "delete_user"
msgid "Delete an user"
msgid "Delete a user"
msgstr ""

msgctxt "delete_confirmation"
msgid "This will delete your user details and anonymise all of your contributions. Please re-enter your user name to confirm."
msgstr ""

msgctxt "danger_zone"
msgid "Danger Zone"
msgstr ""

msgctxt "diff_add"
Expand Down
8 changes: 8 additions & 0 deletions po/common/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,14 @@ msgctxt "delete_user"
msgid "Delete an user"
msgstr "Delete an user"

msgctxt "delete_confirmation"
msgid "This will delete your user details and anonymise all of your contributions. Please re-enter your user name to confirm."
msgstr "This will delete your user details and anonymise all of your contributions. Please re-enter your user name to confirm."

msgctxt "danger_zone"
msgid "Danger Zone"
msgstr "Danger Zone"

msgctxt "diff_add"
msgid "Added:"
msgstr "Added:"
Expand Down
14 changes: 8 additions & 6 deletions templates/web/pages/user_form/user_form_page.tt.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

<!-- Start form -->

<form method="post" action="/cgi/user.pl" enctype="multipart/form-data">
<form method="post" action="/cgi/user.pl" enctype="multipart/form-data" id="user_form">
[% FOREACH section IN sections %]

[% IF section.name %]
Expand Down Expand Up @@ -127,12 +127,14 @@
<p>[% lang("unsubscribe_info") %]</p>
[% END %]

[% IF admin %]
<label>
<input type="checkbox" name="delete" onchange="if (this.checked) { if (!confirm('This action cannot be undone, are you sure you want to delete the user?')) { this.checked = false }}" />
[% lang("delete_user") %]
</label>
[% IF userid %]
<fieldset>
<legend class="text_warning">[% lang("danger_zone") %]</legend>
<input type="button" name=".delete" class="button text_warning" value="[% lang("delete_user") %]" onclick="if ('[% userid %]'.localeCompare(prompt('[% lang("delete_confirmation") %]'),undefined,'base') === 0) {document.getElementById('delete_input').value='on';document.getElementById('user_form').submit();}"/>
<input type="hidden" name="delete" id="delete_input"/>
</fieldset>
[% END %]

<input type="hidden" name="action" value="process" />
<input type="hidden" name="type" value="[% type %]" />
[% IF userid %]
Expand Down

0 comments on commit 6a294d0

Please sign in to comment.