Skip to content

Commit

Permalink
Add support user
Browse files Browse the repository at this point in the history
  • Loading branch information
elceebee committed Dec 14, 2023
1 parent 614e722 commit f079ae6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
7 changes: 6 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ def sign_in_user
end

def current_user
@current_user ||= sign_in_user
@current_user ||= support_user || sign_in_user
end

def support_user
@support_user ||=
sign_in_user.support_user? ? SupportUser.find(sign_in_user.id) : nil
end
end
6 changes: 2 additions & 4 deletions app/models/systems_support.rb → app/models/support_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
#
# index_users_on_email (email) UNIQUE
#
class SystemsSupport < User
class SupportUser < User
default_scope { where(systems_support: true) }
def organisations(scope = :all)
#scope can be :all, :placements or :claims?


[*School.public_send(scope), *Provider.public_send(scope)]
end
end
4 changes: 4 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ class User < ApplicationRecord
validates :last_name, presence: true
validates :email, presence: true
validates :email, uniqueness: { case_sensitive: false }

def support_user?
systems_support
end
end

0 comments on commit f079ae6

Please sign in to comment.