API login/logout with http header token
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
module TokenVerification
|
||||
extend ActiveSupport::Concern
|
||||
include ActionController::HttpAuthentication::Token::ControllerMethods
|
||||
|
||||
included do
|
||||
before_action :authenticate
|
||||
@@ -15,14 +16,9 @@ module TokenVerification
|
||||
def authenticate_token
|
||||
authenticate_with_http_token do |token, options|
|
||||
#@current_user = User.find_by(api_key: token)
|
||||
@device_access = DeviceAccess.find_by_token(token)
|
||||
if @device_access
|
||||
@log = DeviceAccessLog.new
|
||||
@log.device_access = @device_access
|
||||
@log.api_route = request.env['PATH_INFO']
|
||||
@log.remote_ip = request.remote_ip
|
||||
# @log.client_info =
|
||||
@log.save
|
||||
@user = Employee.authenticate_token(token)
|
||||
if @user
|
||||
#Maybe log - login?
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user