Sha256: 87d9828cfa4d51910de76340870a23e9adb3f54d8bf308541509e1e073d04caf

Contents?: true

Size: 688 Bytes

Versions: 4

Compression:

Stored size: 688 Bytes

Contents

module RegistrationTokenValidation
  class << self
    def before(controller)
      @token = controller.params[:registration_token]
      @controller = controller
      controller.redirect_to controller.new_user_session_path unless valid?
    end

    def valid?
      @token.present? && resolves?
    end

    def resolves?
      encrypted_token = Devise.token_generator.digest(
        Jobshop::Team, :registration_token, @token)

      configurable = Jobshop::Team.find_by(
        id: @controller.params[:team_id], registration_token: encrypted_token)

      configurable &&
        configurable.registration_token_period_valid? &&
        configurable.owner.blank?
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jobshop-0.0.41 app/controllers/concerns/registration_token_validation.rb
jobshop-0.0.37 app/controllers/concerns/registration_token_validation.rb
jobshop-0.0.29 app/controllers/concerns/registration_token_validation.rb
jobshop-0.0.23 app/controllers/concerns/registration_token_validation.rb