ApiController: remove old authenticate logic
The old logic cannot work anymore as we cannot `find_by api_token`
This commit is contained in:
parent
6837c79dd1
commit
d576d426f4
1 changed files with 0 additions and 25 deletions
|
@ -12,35 +12,10 @@ class APIController < ApplicationController
|
|||
# it should not happen as an empty token is serialized by ''
|
||||
# and a administrateur without token has admin.api_token == nil
|
||||
before_action :ensure_token_is_present
|
||||
before_action :authenticate_user
|
||||
before_action :default_format_json
|
||||
|
||||
def authenticate_user
|
||||
if !valid_token?
|
||||
request_http_token_authentication
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def valid_token?
|
||||
administrateur.present?
|
||||
end
|
||||
|
||||
def administrateur
|
||||
@administrateur ||= (authenticate_with_bearer_token || authenticate_with_param_token)
|
||||
end
|
||||
|
||||
def authenticate_with_bearer_token
|
||||
authenticate_with_http_token do |token, options|
|
||||
Administrateur.find_by(api_token: token)
|
||||
end
|
||||
end
|
||||
|
||||
def authenticate_with_param_token
|
||||
Administrateur.find_by(api_token: params[:token])
|
||||
end
|
||||
|
||||
def default_format_json
|
||||
request.format = "json" if !request.params[:format]
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue