Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delay and or resend Devise's confirmation email for manually created users

I'm using Devise to allow user signup as-well-as using my own user admin to create users manually. When I create a user in the admin, Devise sends a confirmation immediately to the new user. I believe this is due to the fact that both devise and my admin use the same model. How do I delay this email until the administrator is ready to send it?

Additionally, Devise's validation is requiring the admin set a password for the new user. I would much prefer the manually created users specify their own password when they respond the confirmation. Right now manually created users will not know their password unless I send it too them in a supplemental email.

like image 372
Tim Santeford Avatar asked Dec 03 '10 07:12

Tim Santeford


2 Answers

@user.skip_confirmation! confirms the user, so the user can log in without using the confirmation.

This works for me in devise 3.5

Stop devise to send confirmation email while creating user.

@user.skip_confirmation_notification!  

Send confirmation instructions later

@user.send_confirmation_instructions 
like image 90
Jashwant Avatar answered Oct 05 '22 13:10

Jashwant


We do this in one of our apps. You can tell Devise NOT to automatically deliver the confirmation like this:

@user.skip_confirmation! 

And then later, you can do

Devise::Mailer.confirmation_instructions(@user).deliver 

For Rails 2.x you'd do something like:

DeviseMailer.deliver_confirmation_instructions(@user) 
like image 40
Ryenski Avatar answered Oct 05 '22 13:10

Ryenski