rename find_and_verify => authenticate
This commit is contained in:
parent
87933d3567
commit
40ed59a231
4 changed files with 5 additions and 5 deletions
|
@ -33,7 +33,7 @@ class API::V2::BaseController < ApplicationController
|
|||
def api_token
|
||||
if @api_token.nil?
|
||||
@api_token = APIToken
|
||||
.find_and_verify(authorization_bearer_token)
|
||||
.authenticate(authorization_bearer_token)
|
||||
&.tap { _1.touch(:last_v2_authenticated_at) } || false
|
||||
end
|
||||
@api_token
|
||||
|
|
|
@ -4,7 +4,7 @@ class APIController < ApplicationController
|
|||
protected
|
||||
|
||||
def find_administrateur_for_token(procedure)
|
||||
api_token = APIToken.find_and_verify(authorization_bearer_token)
|
||||
api_token = APIToken.authenticate(authorization_bearer_token)
|
||||
if api_token.present? && api_token.context.fetch(:procedure_ids).include?(procedure.id)
|
||||
api_token.touch(:last_v1_authenticated_at)
|
||||
api_token.administrateur
|
||||
|
|
|
@ -55,7 +55,7 @@ class APIToken < ApplicationRecord
|
|||
[api_token, bearer.to_string]
|
||||
end
|
||||
|
||||
def find_and_verify(bearer_string)
|
||||
def authenticate(bearer_string)
|
||||
bearer = BearerToken.from_string(bearer_string)
|
||||
|
||||
return if bearer.nil?
|
||||
|
|
|
@ -107,13 +107,13 @@ describe APIToken, type: :model do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#find_and_verify' do
|
||||
describe '#authenticate' do
|
||||
let(:api_token_and_packed_token) { APIToken.generate(administrateur) }
|
||||
let(:api_token) { api_token_and_packed_token.first }
|
||||
let(:packed_token) { api_token_and_packed_token.second }
|
||||
let(:bearer_token) { packed_token }
|
||||
|
||||
subject { APIToken.find_and_verify(bearer_token) }
|
||||
subject { APIToken.authenticate(bearer_token) }
|
||||
|
||||
context 'with the legit packed token' do
|
||||
it { is_expected.to eq(api_token) }
|
||||
|
|
Loading…
Reference in a new issue