mirror of
http://ghproxy.cn/https://github.com/multunus/onemdm-server
synced 2025-12-06 10:14:59 +00:00
Heartbeat API with device token authentication
This commit is contained in:
@@ -1,5 +1,20 @@
|
||||
class ApplicationController < ActionController::Base
|
||||
# Prevent CSRF attacks by raising an exception.
|
||||
# For APIs, you may want to use :null_session instead.
|
||||
protect_from_forgery with: :exception
|
||||
protect_from_forgery with: :null_session
|
||||
|
||||
def authenticate_device
|
||||
authenticate_with_token || render_unauthorized
|
||||
end
|
||||
|
||||
def authenticate_device
|
||||
authenticate_or_request_with_http_token do |token, options|
|
||||
@device = Device.find_by(access_token: token)
|
||||
@device != nil
|
||||
end
|
||||
end
|
||||
|
||||
def render_unauthorized
|
||||
render json: "Bad token", status: :unauthorised
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user