mercredi 30 mars 2016

How did I get a user with sign_in_count 0 in devise?

My admin dashboard page started choking due to a division by 0, which it turns out was due to a user getting a sign_in_count of 0.

Does anyone have ideas on how this could have happened, or how I can find out what happened?

Various info that could be useful:

  • I can see that the user actually did manage to use the site, performing actions that requires the current_user functional.

  • This is user over #7000 on my site, so it's not a normal configuration error.

  • The current_sign_in_at and current_sing_in_ip was not set at all - they are nil.

  • Using Rails 3.2.21, Ruby 2.0.0, Devise 3.2.4.

  • The user created his account using google+.

This is my authentication.rb code that is being run for google+:

        newuser = User.where(:email => user_email).first_or_create!(:password => *a_generated_password*)
        newuser.save
        newuser.authentications << auth
        auth.post_frequency = Authentication::PF_NOPOST
        auth.save
        newuser.save
        newuser.profile.tryAutomaticNewRealName(auth)
        flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => auth.provider.capitalize
        sign_in_and_redirect auth.user, :event => :authentication

I know that newuser.profile.tryAutomaticNewRealName(auth) executed correct because the real name was stored.

Aucun commentaire:

Enregistrer un commentaire