Skip to content
This repository has been archived by the owner on Jan 1, 2024. It is now read-only.

Vanity identifies separate participants before/after log in #140

Closed
phillbaker opened this issue Oct 11, 2013 · 7 comments
Closed

Vanity identifies separate participants before/after log in #140

phillbaker opened this issue Oct 11, 2013 · 7 comments

Comments

@phillbaker
Copy link
Collaborator

I.e. Vanity will show different alternatives to a user before/after logging in, if current_user returns nil before login and then the user object after login.

To fix this, instead of a use_vanity :current_user, we're using use_vanity :previous_vanity_cookie_or_current_user with

  # Default Vanity check's current_user with a fall back to a cookie. However,
  # with user sign in, it's possible to visit the site not-logged in, get
  # cookied and shown alternative A, then sign in and based on user.id, get
  # shown alternative B.
  # This implementation prefers an initial vanity cookie id over a new user.id
  # to avoid the flash of alternative B (FOAB). Of course, it falls back to default
  # Vanity cookie if all are nil.
  # The returned object must respond to `id` so a struct is used.
  def previous_vanity_cookie_or_current_user
    @vanity_user ||= Struct.new(:id)
    vanity_user = @vanity_user.new(cookies["vanity_id"]) if cookies["vanity_id"]
    vanity_user || current_user
  end
@tute
Copy link

tute commented Oct 11, 2013

👍, thanks for your work @phillbaker!

@phillbaker
Copy link
Collaborator Author

Addressed also here: #49 with links to other relevant issues.

@phillbaker
Copy link
Collaborator Author

Closing in favor of #49 as it's got the potential to fix this. Also related to #10.

@phillbaker
Copy link
Collaborator Author

Also addressed by 6588ca8

@davidguthu
Copy link
Contributor

Phil - I'm thinking about this scenario..

  • logged out user gets vanity id
  • user goes through some process requiring account registration and logs in
  • user then goes to another computer and gets new vanity id
  • user logs in with the account created from before on other computer
  • we should merge participant records from the two separate vanity_ids into just one of those ids so we can track the behavior of this user across the two machines when they were logged in and logged out.\

Thoughts?

@phillbaker
Copy link
Collaborator Author

@davidguthu that scenario is approached by #49, if you wanted to review and see if you could bring it up to date, that'd be amazing!

@davidguthu
Copy link
Contributor

Sounds good Phil - I'll review and make some suggestions this weekend I hope, latest early next week.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants