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:
parent
7b4ef39014
commit
9a930c8d99
1 changed files with 12 additions and 4 deletions
|
|
@ -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']
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue