mardi 21 juin 2016

Rails Devise Ajax - Successful login but refresh the page and I'm not logged in

Using an overridden devise method (this is Devise 3.0.2) it seems I have a successful login via ajax. But if I refresh the page I am not logged in.

The overridden method is as follows:

 def create
    resource = User.find_for_database_authentication(email: params[:user][:email])
    return invalid_login_attempt unless resource

    if resource.valid_password?(params[:user][:password])
      sign_in :user, resource
      after_sign_in_path_for(resource)
      return render :json => {status: 200}
    end

    invalid_login_attempt
  end

If I was to do the same with a standard html call it works fine. Is there anything else I need to do to remain signed in?

Thank you

ET

Aucun commentaire:

Enregistrer un commentaire