diff options
author | Timothy Andrew <mail@timothyandrew.net> | 2016-06-16 08:24:13 +0530 |
---|---|---|
committer | Timothy Andrew <mail@timothyandrew.net> | 2016-06-16 08:24:13 +0530 |
commit | 7ee0898a9ec4a03c9a55841b1cbea67add460c50 (patch) | |
tree | 02715669032caed346c063a1e56db826f167fca2 /app/models/user.rb | |
parent | faa0e3f7580bc38d4d12916b4589c64d6c2678a7 (diff) | |
download | gitlab-ce-7ee0898a9ec4a03c9a55841b1cbea67add460c50.tar.gz |
Implement @DouweM's feedback.
- Extract a duplicated `redirect_to`
- Fix a typo: "token", not "certificate"
- Have the "Expires at" datepicker be attached to a text field, not inline
- Have both private tokens and personal access tokens verified in a
single "authenticate_from_private_token" method, both in the
application and API. Move relevant logic to
`User#find_by_personal_access_token`
- Remove unnecessary constants relating to API auth. We don't need a
separate constant for personal access tokens since the param is the
same as for private tokens.
Diffstat (limited to 'app/models/user.rb')
-rw-r--r-- | app/models/user.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 65fe88e0287..388e2652ba9 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -269,6 +269,11 @@ class User < ActiveRecord::Base find_by!('lower(username) = ?', username.downcase) end + def find_by_personal_access_token(token_string) + personal_access_token = PersonalAccessToken.active.find_by_token(token_string) if token_string + personal_access_token.user if personal_access_token + end + def by_username_or_id(name_or_id) find_by('users.username = ? OR users.id = ?', name_or_id.to_s, name_or_id.to_i) end |