Sha256: abbd0fd2c3866fdaa4fb144e40ad8ef5cb53209fcdc3622d8a5dd34b1054799f

Contents?: true

Size: 1.16 KB

Versions: 17

Compression:

Stored size: 1.16 KB

Contents

module PushType
  class ConfirmationsController < Devise::ConfirmationsController
    layout 'push_type/auth'

    def show
      self.resource = resource_class.find_by_confirmation_token digested_token
      super if resource.nil? or resource.confirmed?
    end

    def update
      self.resource = resource_class.find_by_confirmation_token! digested_token
      resource.assign_attributes(permitted_params)

      if resource.valid?
        self.resource.confirm!
        set_flash_message :notice, :confirmed
        sign_in_and_redirect resource_name, resource
      else
        render action: 'show'
      end
    end

    private

    def permitted_params
      params.fetch(resource_name, {}).permit(:confirmation_token, :password, :password_confirmation)
    end

    def digested_token
      @digested_token ||= Devise.token_generator.digest(self, :confirmation_token, original_token)
    end

    def original_token
      @original_token ||= if params[:confirmation_token].present?
        params[:confirmation_token]
      elsif params[resource_name].try(:[], :confirmation_token).present?
        params[resource_name][:confirmation_token]
      end
    end

  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
push_type_auth-0.5.1 app/controllers/push_type/confirmations_controller.rb
push_type_auth-0.5.0 app/controllers/push_type/confirmations_controller.rb
push_type_auth-0.5.0.alpha.5 app/controllers/push_type/confirmations_controller.rb
push_type_auth-0.5.0.alpha.4 app/controllers/push_type/confirmations_controller.rb
push_type_auth-0.5.0.alpha.3 app/controllers/push_type/confirmations_controller.rb
push_type_auth-0.5.0.alpha.2 app/controllers/push_type/confirmations_controller.rb
push_type_auth-0.5.0.alpha.1 app/controllers/push_type/confirmations_controller.rb
push_type_auth-0.4.0 app/controllers/push_type/confirmations_controller.rb
push_type_auth-0.4.0.beta.3 app/controllers/push_type/confirmations_controller.rb
push_type_auth-0.3.3 app/controllers/push_type/confirmations_controller.rb
push_type_auth-0.3.1 app/controllers/push_type/confirmations_controller.rb
push_type_auth-0.2.1 app/controllers/push_type/confirmations_controller.rb
push_type_auth-0.2.0 app/controllers/push_type/confirmations_controller.rb
push_type_auth-0.2.0.beta2 app/controllers/push_type/confirmations_controller.rb
push_type_auth-0.1.1 app/controllers/push_type/confirmations_controller.rb
push_type_auth-0.1.0 app/controllers/push_type/confirmations_controller.rb
push_type_auth-0.1.0.beta3 app/controllers/push_type/confirmations_controller.rb