1

I want to be able to create a user using only their e-mail address.

i.e. I want the admin to be able to enter a bunch of e-mail addresses, which will automatically create a new user and password and then e-mail the information to the address provided.

So I am hoping to figure out how to:

Create users using only e-mail addresses (rest can be randomly generated) E-mail users their passwords and login details.

Any suggestions on a best way to approach this? I'm using authlogic for authentication.

Cheers!

Steven Thomas
  • 111
  • 1
  • 3
  • Just a thought, it's generally not a very good idea to email users their passwords and login details. – Gal Jul 19 '11 at 07:45
  • Yeah, but it is going to be a one time use, and the product is generally used by companies internally... if it still seems like a bad idea, any other suggestions? – Steven Thomas Jul 19 '11 at 07:58
  • You could have them set their own passwords after they register, and don't forget to hash them before you insert them into the database. (btw Ben's suggestion is an excellent option to do what you're looking for) – Gal Jul 19 '11 at 08:07

1 Answers1

3

I'd recommend using devise for this, as it handles generating confirmation emails, as well as the routes for confirming an email. A relevant tutorial for allowing users to sign up with just their email addresses: http://blog.devinterface.com/2011/05/two-step-signup-with-devise/

For having an admin create users, it'll be much the same, just generate random passwords+confirmations, and then call user.send_reset_password_instructions to send the email (which can be customized as in Ruby/Rails: How do you customize the mailer templates of Devise? )

see also: Rails Devise: Set password reset token and redirect user

Community
  • 1
  • 1
Ben Taitelbaum
  • 7,343
  • 3
  • 25
  • 45