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): accomplish sign up before accepting the invitation #30

Merged
merged 3 commits into from
Aug 27, 2023

Conversation

andreybakanovsky
Copy link
Contributor

No description provided.

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

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?

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, 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
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
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.

Comment on lines 11 to 15
if user.present?
redirect_to new_user_session_url(email: invitee_email)
else
redirect_to new_user_registration_url(email: invitee_email)
end
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
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
Copy link
Member

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.

@ka8725 ka8725 merged commit ff4e9bc into master Aug 27, 2023
2 checks passed
@VladislavSokov VladislavSokov deleted the dev/account-invitation-not-signed-up 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.

2 participants