0

I have a ruby app and I am using "Authlogic" for user authentication. Users can register and sign-in no problem.

Now I have a csv file into which I have a list of user details which I have to migrate those details to the "users" table. For that I have written a script which goes through the csv file and store the data into "users" table.

The problem is I can't find a way to generate the values for the following fields :

crypted_password password_salt persistence_token

needed by authlogic to work.

Any help?

RRG
  • 457
  • 5
  • 18
  • If authlogic is properly configured, those columns should populate automatically. It might help if we could see your user model and import script. – Greg W Apr 20 '12 at 17:16
  • Yes columns are populated automatically if you register from the site. I need to import users from csv which have plain text passwords. – RRG Apr 21 '12 at 15:01
  • OK after reading this http://stackoverflow.com/questions/2330994/rails-authlogic-password-hashing-algorithm-using-ruby-only I will give it a try using this site http://www.binarylogic.com/2008/11/23/tutorial-upgrade-passwords-easily-with-authlogic/ – RRG Apr 21 '12 at 15:19

2 Answers2

0

Consider watching this railscast, it shows how to generate crypted password by adding salt.

But if in your users table ,password is already salt encrypted, i guess its not possible to generate crypted password again.

In that case you should make your csv import script in such a way, that it doesnot update the password field for existing users.

hitesh israni
  • 1,742
  • 4
  • 25
  • 48
  • The already registered users yes, passwords are encrypted. Maybe I can import the users with plaintext passwords and do something when they sign-in for the first time. – RRG Apr 21 '12 at 15:09
  • better not to touch the password field. and update other fields – hitesh israni Apr 21 '12 at 16:54
0

It was that simple...just used the users model:

user = User.new(:email => email, :login => login, :password => password, :password_confirmation => password)

and the fields where added by authlogic.

RRG
  • 457
  • 5
  • 18