-
Notifications
You must be signed in to change notification settings - Fork 54
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
Allow user authentication from email links #858
Conversation
current_user.anonymize! | ||
sign_out current_user |
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 inverted those two lines, is that okay?
<% token = user.signed_id(purpose: "users.destroy", expires_in: 1.hour) %> | ||
<%= button_to "Supprimer mon compte", profile_path(authentication_token: token), |
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.
Here is where the magic happens ✨
f2652bf
to
c95f44f
Compare
# This prevents flaky specs when the change in lat/lng is zero (1/200) | ||
allow_any_instance_of(RandomizeCoordinatesService) | ||
.to receive(:generate_random_delta) | ||
.and_wrap_original do |method, *args| | ||
original_result = method.call(*args) | ||
original_result.zero? ? 0.001 : original_result | ||
end |
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.
Another approach would be to update the randomness seed but it would impact the production code a bit too much so I went for this.
Je t'ai invité sur le repo. |
Co-authored-by: Emmanuel Cousin <[email protected]>
Summary
As part of #829 I would like to authenticate users right from emails. This PR sets the foundations to do this.
So far we authenticated users using
matches
' tokens orslot_alerts
's tokens.Now we need
users
' tokens: we need communication unrelated to any of the above events.Details
No functional changes should be part of this PR.
It adds a concern for controllers
UserAuthenticationViaSignedId
that complements the usual devise/warden authentication using anauthentication_token
based on globalid.It creates a single partial to DRY those routes:
users#destroy
,matches/users#destroy
, andslot_alerts/users#destroy
.Also DRY those views:
slot_alerts/users#edit
, andmatches/users#edit
... into
users/_confirm_destroy_message
.The goal is to reuse
confirm_destroy_profile_path
from email and sign it with an authentication token.This
users#confirm_destroy
action looks like this:Poke @mininao as you authored the original issue.
The next steps are:
rake
task to identify the appropriate usersconfirm_destroy_profile_path
with an auth token