Merge branch 'use_tokenauthenticatable_method_for_token_lookup' into 'master'
Remove PersonalAccessTokensFinder#find_by method See merge request gitlab-org/gitlab-ce!22617
This commit is contained in:
commit
c12a4a9ac7
|
@ -3,7 +3,7 @@
|
||||||
class PersonalAccessTokensFinder
|
class PersonalAccessTokensFinder
|
||||||
attr_accessor :params
|
attr_accessor :params
|
||||||
|
|
||||||
delegate :build, :find, :find_by, :find_by_token, to: :execute
|
delegate :build, :find, :find_by_id, :find_by_token, to: :execute
|
||||||
|
|
||||||
def initialize(params = {})
|
def initialize(params = {})
|
||||||
@params = params
|
@params = params
|
||||||
|
|
|
@ -460,12 +460,6 @@ class User < ActiveRecord::Base
|
||||||
by_username(username).take!
|
by_username(username).take!
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_by_personal_access_token(token_string)
|
|
||||||
return unless token_string
|
|
||||||
|
|
||||||
PersonalAccessTokensFinder.new(state: 'active').find_by_token(token_string)&.user # rubocop: disable CodeReuse/Finder
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns a user for the given SSH key.
|
# Returns a user for the given SSH key.
|
||||||
def find_by_ssh_key_id(key_id)
|
def find_by_ssh_key_id(key_id)
|
||||||
Key.find_by(id: key_id)&.user
|
Key.find_by(id: key_id)&.user
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Remove PersonalAccessTokensFinder#find_by method
|
||||||
|
merge_request: 22617
|
||||||
|
author:
|
||||||
|
type: fixed
|
|
@ -512,11 +512,9 @@ module API
|
||||||
PersonalAccessTokensFinder.new({ user: user, impersonation: true }.merge(options))
|
PersonalAccessTokensFinder.new({ user: user, impersonation: true }.merge(options))
|
||||||
end
|
end
|
||||||
|
|
||||||
# rubocop: disable CodeReuse/ActiveRecord
|
|
||||||
def find_impersonation_token
|
def find_impersonation_token
|
||||||
finder.find_by(id: declared_params[:impersonation_token_id]) || not_found!('Impersonation Token')
|
finder.find_by_id(declared_params[:impersonation_token_id]) || not_found!('Impersonation Token')
|
||||||
end
|
end
|
||||||
# rubocop: enable CodeReuse/ActiveRecord
|
|
||||||
end
|
end
|
||||||
|
|
||||||
before { authenticated_as_admin! }
|
before { authenticated_as_admin! }
|
||||||
|
|
|
@ -92,7 +92,7 @@ describe PersonalAccessTokensFinder do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'with id' do
|
describe 'with id' do
|
||||||
subject { finder(params).find_by(id: active_personal_access_token.id) }
|
subject { finder(params).find_by_id(active_personal_access_token.id) }
|
||||||
|
|
||||||
it { is_expected.to eq(active_personal_access_token) }
|
it { is_expected.to eq(active_personal_access_token) }
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ describe PersonalAccessTokensFinder do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'with token' do
|
describe 'with token' do
|
||||||
subject { finder(params).find_by(token: active_personal_access_token.token) }
|
subject { finder(params).find_by_token(active_personal_access_token.token) }
|
||||||
|
|
||||||
it { is_expected.to eq(active_personal_access_token) }
|
it { is_expected.to eq(active_personal_access_token) }
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ describe PersonalAccessTokensFinder do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'with id' do
|
describe 'with id' do
|
||||||
subject { finder(params).find_by(id: active_personal_access_token.id) }
|
subject { finder(params).find_by_id(active_personal_access_token.id) }
|
||||||
|
|
||||||
it { is_expected.to eq(active_personal_access_token) }
|
it { is_expected.to eq(active_personal_access_token) }
|
||||||
|
|
||||||
|
@ -221,7 +221,7 @@ describe PersonalAccessTokensFinder do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'with token' do
|
describe 'with token' do
|
||||||
subject { finder(params).find_by(token: active_personal_access_token.token) }
|
subject { finder(params).find_by_token(active_personal_access_token.token) }
|
||||||
|
|
||||||
it { is_expected.to eq(active_personal_access_token) }
|
it { is_expected.to eq(active_personal_access_token) }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue