From 2e47bcf5cbefc891ee6ec2790209b3ba10d8536a Mon Sep 17 00:00:00 2001 From: Priit Tark Date: Tue, 17 Feb 2015 02:21:23 +0200 Subject: [PATCH] Merge updates and fixes --- app/controllers/application_controller.rb | 8 -------- app/controllers/epp/domains_controller.rb | 2 +- app/models/ability.rb | 8 +++++++- db/schema.rb | 2 +- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 698cbfa88..047104c6b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -15,14 +15,6 @@ class ApplicationController < ActionController::Base redirect_to admin_dashboard_path, alert: exception.message end - def current_ability - if defined?(current_api_user) && current_api_user.present? - current_api_user.ability - else - current_user.ability - end - end - def after_sign_in_path_for(_resource) if session[:user_return_to] && session[:user_return_to] != login_path return session[:user_return_to].to_s diff --git a/app/controllers/epp/domains_controller.rb b/app/controllers/epp/domains_controller.rb index eac99120e..4530fc180 100644 --- a/app/controllers/epp/domains_controller.rb +++ b/app/controllers/epp/domains_controller.rb @@ -208,7 +208,7 @@ class Epp::DomainsController < EppController return domain if domain.auth_info == params[:parsed_frame].css('authInfo pw').text - if (domain.registrar != current_api_user.registrar) && secure[:secure] == true + if (domain.registrar != current_user.registrar) && secure[:secure] == true epp_errors << { code: '2302', msg: I18n.t('errors.messages.domain_exists_but_belongs_to_other_registrar'), diff --git a/app/models/ability.rb b/app/models/ability.rb index 9980e9709..666ea6685 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -5,7 +5,13 @@ class Ability alias_action :show, :create, :update, :destroy, to: :crud @user = user || AdminUser.new - @user.roles.each { |role| send(role) } if @user.roles + + case @user.class.to_s + when 'AdminUser' + @user.roles.each { |role| send(role) } if @user.roles + when 'ApiUser' + epp + end can :show, :dashboard end diff --git a/db/schema.rb b/db/schema.rb index c963f2c75..6a889a676 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150212125339) do +ActiveRecord::Schema.define(version: 20150213104014) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql"