Class: Pageflow::UserPolicy Private

Inherits:
ApplicationPolicy show all
Defined in:
app/policies/pageflow/user_policy.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Defined Under Namespace

Classes: Scope

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, managed_user) ⇒ UserPolicy

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of UserPolicy.



36
37
38
39
# File 'app/policies/pageflow/user_policy.rb', line 36

def initialize(user, managed_user)
  @user = user
  @managed_user = managed_user
end

Instance Attribute Details

#userObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



34
35
36
# File 'app/policies/pageflow/user_policy.rb', line 34

def user
  @user
end

Instance Method Details

#add_account_to?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


54
55
56
# File 'app/policies/pageflow/user_policy.rb', line 54

def 
  Pageflow.config.allow_multiaccount_users
end

#admin?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


78
79
80
# File 'app/policies/pageflow/user_policy.rb', line 78

def admin?
  @user.admin?
end

#create?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


45
46
47
# File 'app/policies/pageflow/user_policy.rb', line 45

def create?
  index?
end

#create_any?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


41
42
43
# File 'app/policies/pageflow/user_policy.rb', line 41

def create_any?
  index?
end

#delete_own_user?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


94
95
96
# File 'app/policies/pageflow/user_policy.rb', line 94

def delete_own_user?
  Pageflow.config.authorize_user_deletion.call(@managed_user) == true
end

#destroy?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


74
75
76
# File 'app/policies/pageflow/user_policy.rb', line 74

def destroy?
  deny_sign_in?
end

#index?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


49
50
51
52
# File 'app/policies/pageflow/user_policy.rb', line 49

def index?
  @user.admin? ||
    @user.memberships.on_accounts.where(role: 'manager').any?
end

#read?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


58
59
60
61
62
63
64
# File 'app/policies/pageflow/user_policy.rb', line 58

def read?
  manager_accounts = AccountPolicy::Scope
                     .new(@user, Account).member_addable
  managed_user_accounts = AccountPolicy::Scope
                          .new(@managed_user, Account).resolve
  manager_accounts.intersect?(managed_user_accounts)
end

#redirect_to_user?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


66
67
68
# File 'app/policies/pageflow/user_policy.rb', line 66

def redirect_to_user?
  read?
end

#see_admin_status?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


86
87
88
89
90
91
92
# File 'app/policies/pageflow/user_policy.rb', line 86

def see_admin_status?
  if permissions_config.only_admins_may_see_admin_boolean
    admin?
  else
    read?
  end
end

#set_admin?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


82
83
84
# File 'app/policies/pageflow/user_policy.rb', line 82

def set_admin?
  admin?
end

#suspend?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


70
71
72
# File 'app/policies/pageflow/user_policy.rb', line 70

def suspend?
  deny_sign_in?
end