Skip to content

Commit d2b7f6a

Browse files
author
Irene
committed
Validate checkbox in server
1 parent 298bede commit d2b7f6a

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

app/controllers/users_controller.rb

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,17 @@ def verify_destroying_user
9797
end
9898

9999
def destroy_user
100-
user = authenticate_current_user
101-
token = VerificationToken.delete_user.find_by!(user: user, token: params[:id])
102-
username = user.login
103-
sign_out if current_user == user
104-
user.destroy
105-
redirect_to root_url, notice: "The account #{username} has been permanently destroyed."
100+
im_sure = params[:id]
101+
if im_sure != "1"
102+
redirect_to verify_destroying_user_url, notice: "Please check the checkbox after you have read the instructions."
103+
else
104+
user = authenticate_current_user
105+
token = VerificationToken.delete_user.find_by!(user: user, token: params[:id])
106+
username = user.login
107+
sign_out if current_user == user
108+
user.destroy
109+
redirect_to root_url, notice: "The account #{username} has been permanently destroyed."
110+
end
106111
end
107112

108113
def send_destroy_email

app/views/users/verify_destroying_user.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<ul>
66
<li>You will lose all your acquired exercise points. We will not be able to recover them.</li>
77
<li>You will not be able to receive a grade from any TestMyCode course.</li>
8-
<li>We will not be able to verify the authencity of any certificates that you have generated.</li>
8+
<li>We will not be able to verify the authenticity of any certificates that you have generated.</li>
99
<ul>
1010
</div>
1111

0 commit comments

Comments
 (0)