cschiewek / devise_ldap_authenticatable

Devise Module for LDAP
MIT License
593 stars 359 forks source link

Remember me #215

Closed rami85 closed 8 years ago

rami85 commented 8 years ago

Hi,

In my User Model I have:

devise :ldap_authenticatable, :rememberable, :trackable

and in my user_table I have the remember_created_at field...

The sign in without 'Remember me' works correctly. If I check the 'Remember me' I show this error:

authenticable_salt returned nil for the User model. In order to use rememberable, you must ensure a password is always set or have a remember_token column in your model or implement your own rememberable_value in the model with custom logic.

regards

highway11 commented 8 years ago

Any fix for this? I'm having the same issue

ianagne commented 8 years ago

If anyone is still having this problem, add a remember_token column to your users table.

Here is a sample migration:

class DeviseCreateUsers < ActiveRecord::Migration
  def change
    create_table(:users) do |t|
      t.string :email, null: false, default: ''

      ## Rememberable
      t.datetime :remember_created_at
      t.string   :remember_token  # Add this column to fix the error

      ## Trackable
      t.integer  :sign_in_count, default: 0, null: false
      t.datetime :current_sign_in_at
      t.datetime :last_sign_in_at
      t.inet     :current_sign_in_ip
      t.inet     :last_sign_in_ip

      ## Lockable
      t.integer  :failed_attempts, default: 0, null: false
      t.string   :unlock_token
      t.datetime :locked_at

      t.timestamps null: false
    end

    add_index :users, :remember_token, unique: true
    add_index :users, :email, unique: true
    add_index :users, :unlock_token, unique: true
  end
end
kennym commented 7 years ago

+1 adding remember_token column fixed the issue for me.