Sha256: 1426e11fdbe08b0f35076d3432f1ce8be545466248272f93f116a49a06ef11f8
Contents?: true
Size: 1.26 KB
Versions: 2
Compression:
Stored size: 1.26 KB
Contents
require 'public_suffix' module RestPack module Web class Context attr_accessor :domain, :application, :channel, :configurations, :user, :user_id, :request def initialize(env) restpack = env[:restpack] if restpack @request = restpack[:request] @domain = restpack[:domain] @application = restpack[:application] @channel = restpack[:channel] @configurations = restpack[:configurations] @user = restpack[:user] @user_id = @user[:id] if @user end end def is_authenticated? @user.present? end def home_domain @application.home_domain || "www.#{root_domain}" end def auth_domain @application.auth_domain || "auth.#{root_domain}" end def logout_url(next_url = nil) #TODO: GJ: whitelist the next_url next_url ||= "http://#{home_domain}/" "http://#{auth_domain}/auth/logout?next=#{next_url}" end def login_url(provider = :twitter, next_url = nil) next_url ||= "http://#{home_domain}/" "http://#{auth_domain}/auth/#{provider}?next=#{next_url}" end def root_domain PublicSuffix.parse(@domain.host).domain end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
restpack-web-0.1.47 | lib/restpack-web/context.rb |
restpack-web-0.1.46 | lib/restpack-web/context.rb |