about summary refs log tree commit diff
path: root/app/policies/application_policy.rb
blob: 163b81e9e655cc9592097336d0af1ff907dd057d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# frozen_string_literal: true

class ApplicationPolicy
  attr_reader :current_account, :record

  def initialize(current_account, record)
    @current_account = current_account
    @record          = record
  end

  private

  def current_user
    current_account&.user
  end

  def user_signed_in?
    !current_user.nil?
  end

  def role
    current_user&.role || UserRole.nobody
  end
end