1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -05:00
heartcombo--devise/app/controllers/devise/confirmations_controller.rb

48 lines
1.4 KiB
Ruby
Raw Normal View History

class Devise::ConfirmationsController < DeviseController
2010-02-08 19:07:24 +01:00
# GET /resource/confirmation/new
def new
2013-04-13 23:21:46 -07:00
self.resource = resource_class.new
2010-02-08 19:07:24 +01:00
end
# POST /resource/confirmation
def create
self.resource = resource_class.send_confirmation_instructions(resource_params)
yield resource if block_given?
2010-02-08 19:07:24 +01:00
if successfully_sent?(resource)
2014-02-25 22:12:55 +05:30
respond_with({}, location: after_resending_confirmation_instructions_path_for(resource_name))
2011-06-20 22:30:25 -03:00
else
respond_with(resource)
2010-02-08 19:07:24 +01:00
end
end
2009-11-10 18:55:13 -02:00
# GET /resource/confirmation?confirmation_token=abcdef
def show
self.resource = resource_class.confirm_by_token(params[:confirmation_token])
yield resource if block_given?
2009-10-12 08:37:28 -03:00
2009-10-11 22:11:58 -03:00
if resource.errors.empty?
set_flash_message(:notice, :confirmed) if is_flashing_format?
respond_with_navigational(resource){ redirect_to after_confirmation_path_for(resource_name, resource) }
else
2014-02-25 22:12:55 +05:30
respond_with_navigational(resource.errors, status: :unprocessable_entity){ render :new }
end
end
protected
# The path used after resending confirmation instructions.
def after_resending_confirmation_instructions_path_for(resource_name)
new_session_path(resource_name) if is_navigational_format?
end
# The path used after confirmation.
def after_confirmation_path_for(resource_name, resource)
if signed_in?
signed_in_root_path(resource)
else
new_session_path(resource_name)
end
end
end