-
Notifications
You must be signed in to change notification settings - Fork 1
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(account invitation): accomplish sign up before accepting the invitation #30
Conversation
@@ -16,6 +23,6 @@ def update | |||
private | |||
|
|||
helper_method memoize def received_invitation | |||
AccountInvitation.unaccepted.for(current_user).find_by!(token: ps.fetch(:token)) | |||
AccountInvitation.unaccepted.for(current_user).find_by!(token: ps[: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.
what was the problem with the previous implementation? revert it?
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.
... ok, I've seen the main idea of thefetch
for us: errors. Ok
redirect_to new_user_session_url(email: AccountInvitation.find_by!(token: ps.fetch(:token)).email) | ||
session[:after_authentication_url] = request.fullpath | ||
|
||
invitee_email = AccountInvitation.find_by!(token: ps[:token]).email |
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.
invitee_email = AccountInvitation.find_by!(token: ps[:token]).email | |
invitee_email = AccountInvitation.find_by!(token: ps.fetch(:token)).email |
If the ps.fetch(:token)
bothers you, create a private method token_param
or something and use it in all places.
if user.present? | ||
redirect_to new_user_session_url(email: invitee_email) | ||
else | ||
redirect_to new_user_registration_url(email: invitee_email) | ||
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.
if user.present? | |
redirect_to new_user_session_url(email: invitee_email) | |
else | |
redirect_to new_user_registration_url(email: invitee_email) | |
end | |
redirect_url = user ? new_user_session_url(email: invitee_email) : new_user_registration_url(email: invitee_email) | |
redirect_to redirect_url |
it's a bit more DRY
@@ -4,8 +4,13 @@ class AcceptAccountInvitationsController < ApplicationController | |||
def show | |||
return if user_signed_in? | |||
|
|||
session[:after_sign_in_url] = request.fullpath | |||
redirect_to new_user_session_url(email: AccountInvitation.find_by!(token: ps.fetch(:token)).email) | |||
session[:after_authentication_url] = request.fullpath |
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.
Why changed the key :after_sign_in_url
to :after_authentication_url
? :after_authentication_url
is longer, harder to write and spell.
No description provided.