mirror of
https://github.com/internetee/registry.git
synced 2025-07-01 16:53:37 +02:00
Refactored contact with ability
This commit is contained in:
parent
62f8061e10
commit
96d1c60dd8
33 changed files with 763 additions and 1045 deletions
|
@ -2,16 +2,25 @@ class Ability
|
|||
include CanCan::Ability
|
||||
|
||||
def initialize(user)
|
||||
alias_action :create, :read, :update, :destroy, to: :crud
|
||||
alias_action :show, :create, :update, :destroy, to: :crud
|
||||
|
||||
@user = user || AdminUser.new
|
||||
@user.roles.each { |role| send(role) } if @user.roles
|
||||
|
||||
return if @user.roles || @user.roles.any?
|
||||
|
||||
can :show, :dashboard
|
||||
end
|
||||
|
||||
def epp
|
||||
# Epp::Contact
|
||||
can(:info, Epp::Contact) { |c, pw| c.registrar_id == @user.registrar_id || c.auth_info == pw }
|
||||
can(:check, Epp::Contact)
|
||||
can(:create, Epp::Contact)
|
||||
can(:update, Epp::Contact) { |c, pw| c.registrar_id == @user.registrar_id && c.auth_info == pw }
|
||||
can(:delete, Epp::Contact) { |c, pw| c.registrar_id == @user.registrar_id && c.auth_info == pw }
|
||||
can(:renew, Epp::Contact)
|
||||
can(:view_password, Epp::Contact) { |c| c.registrar_id == @user.registrar_id }
|
||||
end
|
||||
|
||||
def user
|
||||
can :show, :dashboard
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue