Skip to content

Bugfix/store recognisable session on registration#106

Open
quorauk wants to merge 3 commits into
masterfrom
bugfix/store-recognisable-session-on-registration
Open

Bugfix/store recognisable session on registration#106
quorauk wants to merge 3 commits into
masterfrom
bugfix/store-recognisable-session-on-registration

Conversation

@quorauk
Copy link
Copy Markdown

@quorauk quorauk commented Aug 25, 2023

Changes

Stores a recognisable session on registration

I noticed that sessions aren't stored when a user first registers, so the first actual sign in works without hitting Guard

I'm not particularly comfortable with this change, so let me know if it has some horrid gotchas i'm not aware of 😛

Ticket

#105

Before submitting have you:

  • Included a link to any relevant ticket
  • Included links to any github issues
  • Prefix the title with the PR type (Feature, Bugfix, Documentation, Chore)

After submitting remember to:

  • Mark the ticket as ready for review
  • Include the PR on the ticket
  • Assign a single reviewer

@quorauk quorauk changed the title store recognisable session on registration Bugfix/store recognisable session on registration Aug 25, 2023
@quorauk quorauk marked this pull request as ready for review August 25, 2023 14:32
# After the user has been signed up, we save the ip address in the
# DeviseRecognisable::RecognisableSession table.
def store_recognisable_details
return unless resource.persisted?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @quorauk! I think the main question I'd be asking is if we have some social proof that this is the right way to add a hook after #create e.g. this guard is enough to confirm that we should be creating a RecogniseableSession. Do you have anything you can point to?

def store_recognisable_details
return unless resource.persisted?
DeviseRecognisable::RecognisableSession.create!(
recognisable: resource_class.find_by(email: params[resource_name][:email]),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Any reason why you can't just pass resource here?

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