Sha256: 86c197520074ab86a9afa144b018de36335dd50c69f2ea47427c25f5cfe694a1
Contents?: true
Size: 1.46 KB
Versions: 2
Compression:
Stored size: 1.46 KB
Contents
module CurrentUserHelpers def login_required if !current_user return respond_to do |format| format.html { redirect_to login_path } format.json { render :json => { 'error' => 'Access Denied' }.to_json } end end end def login_path "#{SsoClyent.path}/auth/sso" end def logout_path "#{SsoClyent.path}/logout" end def signup_path SsoClyent.signup_url end def edit_account_path SsoClyent.edit_account_url end def current_user return nil unless session[:user_id] users = user_klass uid = userid if users.respond_to?(:"find_by_#{uid}") @current_user ||= users.send(:"find_by_#{uid}", session[:user_id]['uid']) end end def user_signed_in? !!current_user end def check_for_login_error api_response current_user_logout if !api_response.is_a? Array and api_response.try(:[],:error).try(:==,'401 Unauthorized') end def current_user_logout session[:user_id] = nil end def user_klass SsoClyent.user_class end def userid SsoClyent.unique_id end def check_if_from_sign_up if from_sign_up = params.delete(:from_sign_up) login_required begin process_params_from_sign_up(from_sign_up) rescue end unless performed? return redirect_to(url_for(params)) end end end end ActionController::Base.send :include, CurrentUserHelpers ActionController::Base.send :before_filter, :check_if_from_sign_up
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sso_clyent-0.0.7.31 | lib/sso_clyent/controllers/current_user_helpers.rb |
sso_clyent-0.0.7.30 | lib/sso_clyent/controllers/current_user_helpers.rb |