Skip to content
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

Merged
merged 3 commits into from
Aug 25, 2023

Conversation

andreybakanovsky
Copy link
Contributor

No description provided.


def update
received_invitation.update!(accepted_at: Time.current)
redirect_to account_path(received_invitation.account_id)
Copy link
Member

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?

Copy link
Contributor Author

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]
Copy link
Member

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.

Copy link
Contributor Author

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
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
protected
private

Learn about protected in Ruby. It's not the same as in the common OOP (like Java).

Copy link
Contributor Author

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

Comment on lines 16 to 18
if (after_sign_in_url = session.delete(:after_sign_in_url)).present?
return after_sign_in_url
end
Copy link
Member

@ka8725 ka8725 Aug 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)

@ka8725 ka8725 merged commit da6fb45 into master Aug 25, 2023
2 checks passed
@VladislavSokov VladislavSokov deleted the dev/account-invitation-not-signed-in branch December 6, 2023 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants