Class: Droom::ConfirmationsController
- Inherits:
-
Devise::ConfirmationsController
- Object
- Devise::ConfirmationsController
- Droom::ConfirmationsController
- Defined in:
- app/controllers/droom/confirmations_controller.rb
Instance Method Summary collapse
- #after_confirmation_path_for(resource_name, resource) ⇒ Object
-
#show ⇒ Object
If user not yet confirmed, show password form (rather than just confirming, as is normal) If already confirmed, allow devise to do whatever a devise does.
-
#update ⇒ Object
the purpose of this is to add another step between user creation and user confirmation, such that we perform the confirmation only if a password is supplied and validates.
Instance Method Details
#after_confirmation_path_for(resource_name, resource) ⇒ Object
45 46 47 |
# File 'app/controllers/droom/confirmations_controller.rb', line 45 def after_confirmation_path_for(resource_name, resource) dashboard_url end |
#show ⇒ Object
If user not yet confirmed, show password form (rather than just confirming, as is normal) If already confirmed, allow devise to do whatever a devise does.
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/droom/confirmations_controller.rb', line 7 def show if self.resource = resource_class.confirm_by_token(params[:confirmation_token]) if resource.confirmed? redirect_to after_sign_in_path_for(resource) else render end elsif user_signed_in? redirect_to after_sign_in_path_for(current_user) else render :template => "devise/confirmations/failure" end end |
#update ⇒ Object
the purpose of this is to add another step between user creation and user confirmation, such that we perform the confirmation only if a password is supplied and validates.
NB. in the tortured RESTfulness of devise, that means turning confirmation#show into a password form and using confirmations#update to update the user object accordingly.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/droom/confirmations_controller.rb', line 27 def update if self.resource = resource_class.where(id: params[:id], confirmation_token: params[resource_name][:confirmation_token]).first result = resource.update_attributes(permitted_params) if result && resource.password_match? :notice, :confirmed resource.confirm! sign_in(resource_name, resource) (resource){ redirect_to after_confirmation_path_for(resource_name, resource) } else # back to the password form :error, :password_error render :action => "show" end else render :template => "devise/confirmations/failure" end end |