coopdevs/timeoverflow

View on GitHub
app/policies/user_policy.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
class UserPolicy < ApplicationPolicy
  def create?
    !user || user.admins?(organization)
  end

  def update?
    user == record || (
      record.organizations.size == 1 &&
      record.organizations.first == organization &&
      user.admins?(organization)
    )
  end
end