Sha256: 6bf755d1fbf2efe403df68f9e2243244fb56fb853577106fa98b889bbeea40dd
Contents?: true
Size: 1.14 KB
Versions: 1
Compression:
Stored size: 1.14 KB
Contents
require 'public_suffix' module RestPack module Web class Context attr_accessor :domain, :application, :channel, :user, :user_id def initialize(env) restpack = env[:restpack] if restpack @domain = restpack[:domain] @application = restpack[:application] @channel = restpack[:channel] @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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
restpack-web-0.1.37 | lib/restpack-web/context.rb |