Just to get it out of the way: I do have emails working in my app.
I just added :confirmable to my user model.
app/models/user.rb
devise :database_authenticatable, :registerable, :omniauthable,
:recoverable, :rememberable, :trackable, :validat开发者_如何转开发able, :confirmable
I do have the confirmable part in the db:
db/schema.rb
create_table "users", :force => true do |t|
...
t.string "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
end
Because of the omniauth I have overwritten registrations_controller
:
app/controllers/registrations_controller.rb
def create
super
session[:omniauth] = nil unless @user.new_record?
end
So what I'm trying to figure out is… what do I need to add in order to:
Get confirmation email sent after the user signs up
Redirect the user to a custom page explaining the email is waiting to be confirmed (which they would get to if they tried signing in again without confirming)(answered here)(should be taken care of automatically?) When the user is verified redirect them to given page
Update: Right now, when I create a user it is automatically confirmed. Why is that?
Ok, so I didn't realize I had the following in my user model:
def send_confirmation_instructions
# stops Devise from automatically sending a confirmation email
end
def confirmation_required?
skip_confirmation!
end
Commenting them out gets the email to be sent. Still trying to figure out how to redirect after sign in if the user isn't confirmed. And trying to figure out how to properly use confirmation_required?
精彩评论