Add admin mode

The API Controller checks if the user is logged in and whether they are an admin, and checks for the X-Admin-Mode header
This commit is contained in:
Justin Edmund 2023-08-24 21:56:41 -07:00
parent 7b4ef39014
commit 9a930c8d99

View file

@ -50,6 +50,14 @@ module Api
@current_user @current_user
end end
def admin_mode
if current_user && current_user.admin? && request.headers['X-Admin-Mode']
@admin_mode ||= request.headers['X-Admin-Mode'] == 'true'
end
@admin_mode
end
def edit_key def edit_key
@edit_key ||= request.headers['X-Edit-Key'] if request.headers['X-Edit-Key'] @edit_key ||= request.headers['X-Edit-Key'] if request.headers['X-Edit-Key']