Sha256: 6c9e382a2e6e4b5b86e24e8616173651ee82208e368d37a7eea8ea4cc32d0f28
Contents?: true
Size: 1.27 KB
Versions: 1
Compression:
Stored size: 1.27 KB
Contents
module Beta # AccessHelpers encapsulates the functionality for whitespacing. This will # usually be included in ApplicationController and acccessed as before_filters module AccessHelpers # Uses redis whitelist and cookies to detect beta access. Redirects on failure. # # @param [String, nil] Location to redirect to on failure. Defaults to system config of Beta URL def whitelist redirection = nil return true unless Beta.environments.include?(::Rails.env) if cookies.signed["#{Beta.namespace}-beta"] == "#{Beta.namespace}-beta-#{request.remote_addr}" return true end return false unless authenticate unless current_user_on_whitelist? redirect_to(redirection || Beta.redirect_url) return end cookies.signed["#{Beta.namespace}-beta"] = "#{Beta.namespace}-beta-#{request.remote_addr}" end # Uses redis whitelist to detect if the given user has beta access # # @param [User] the user to be checked against the list def is_whitelisted? user Beta.redis.sismember("#{Beta.namespace}:#{::Rails.env}:beta", user.try(Beta.uid)) end # Uses `is_whitelisted?` with the value of `current_user` def current_user_on_whitelist? is_whitelisted? current_user end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
beta-0.0.3 | lib/beta/access_helpers.rb |