forked from heartcombo/devise
-
Notifications
You must be signed in to change notification settings - Fork 0
How To: Automatically generate password for users (simpler registration)
DarkCoin edited this page Jun 3, 2011
·
10 revisions
It's now increasingly common for websites to provide "super fast & easy" registration : the user just gives his e-mail. The confirmation e-mail then contains a password generated for the user. If the user is not happy with the password (either wants a super-weak or super-strong one), the ability to change it is given right away when accessing the confirmation link.
This method is used for example by slashdot.org
I'm quite fond of this registration method. I want to implement it with devise. As soon as I find out how to do that, I will share it on this page.
Stay tuned !
One simple not best example
# generate token string
generated_password = User.send(:generate_token, 'encrypted_password')
# change randomly password length in range 8..13 characters
generated_password.slice!(13 - rand(5)..generated_password.length)
# create user
User.create!(:email => email_from_params, :password => generated_password, :confirm_password = generated_password)add generated_password to welcome email body :)