Separated epp login and epp request abilities #2742

This commit is contained in:
Priit Tark 2015-08-19 01:21:16 +03:00
parent 598ab7ba63
commit 34f1d7d254
5 changed files with 83 additions and 61 deletions

View file

@ -56,6 +56,15 @@ class Epp::SessionsController < EppController
success = false
end
if success && @api_user.cannot?(:create, :epp_login)
epp_errors << {
msg: 'Authentication error; server closing connection (API user does not have epp role)',
code: '2501'
}
success = false
end
if success && !ip_white?
epp_errors << {
msg: 'Authentication error; server closing connection (IP is not whitelisted)',

View file

@ -71,7 +71,7 @@ class Registrar::SessionsController < Devise::SessionsController
redirect_to :back and return
end
if @api_user.can_make_api_calls?
if @api_user.can(:create, :epp_login)
unless @api_user.registrar.api_ip_white?(request.ip)
flash[:alert] = I18n.t(:ip_is_not_whitelisted)
redirect_to :back and return

View file

@ -21,7 +21,7 @@ class RegistrarController < ApplicationController
riw = current_user.registrar.registrar_ip_white?(request.ip)
aiw = true
if current_user.can_make_api_calls?
if current_user.can?(:create, :epp_request)
aiw = current_user.registrar.api_ip_white?(request.ip)
end