Skip to content

Sign in possibly succeeds for null user #987

@robingram

Description

@robingram

I wonder if you might have any insight into a strange error that we're getting.

We've been receiving occasional exceptions (a few per week) from our sessions controller where the result of sign_in is success but the user record is nil. Our create action is pretty standard:

def create
  @user = authenticate(params)

  sign_in(@user) do |status|
    if status.success?
      after_login_actions
      redirect_back_or url_after_create
    else
      flash.now.alert = error_message
      render :new, status: :unauthorized
    end
  end
end

after_login_actions is really simple but the first thing it does is call a method on @user, and this is where were getting the errors because @user is nil.

We don't have any custom sign in guards so we're a little confused about why sign_in is either succeeding for an empty user record or blanking it itself somehow.

Any suggestions on what might be causing this or steps to diagnose what's happening?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions