-
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): implement sign in before accepting the invitation #27
Conversation
|
||
def update | ||
received_invitation.update!(accepted_at: Time.current) | ||
redirect_to account_path(received_invitation.account_id) |
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 agree that it still was not working, but it was the correct line. Revert it back? Why removed?
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, let's keep
|
||
def show; end | ||
session[: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.
Better remember after_sign_in_url
in the session, this way the after-sign-in redirect implementation will be easy without knowing the internals of possible workflows current or future.
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.
Global. Beautiful.
end | ||
|
||
private | ||
|
||
helper_method memoize def received_invitation | ||
AccountInvitation.unaccepted.for(current_user).find_by!(token: ps.fetch(:token)) | ||
end | ||
|
||
memoize def the_invitation |
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.
Remove this check, if they sign in and the after-sign-in link is wrong, they will see 404 page and this is fine. In other words, the code already handles this scenario and no need to write special code for that.
end | ||
end | ||
|
||
protected |
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.
protected | |
private |
Learn about protected
in Ruby. It's not the same as in the common OOP (like Java).
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'm aware about. It's just missprint
if (after_sign_in_url = session.delete(:after_sign_in_url)).present? | ||
return after_sign_in_url | ||
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 (after_sign_in_url = session.delete(:after_sign_in_url)).present? | |
return after_sign_in_url | |
end | |
after_sign_in_url = session.delete(:after_sign_in_url) | |
return after_sign_in_url if after_sign_in_url.present? |
(don't assign inside boolean expressions, these side-effects are tricky to read and debug)
No description provided.