diff options
author | Tiago Botelho <tiagonbotelho@hotmail.com> | 2017-02-23 17:47:06 +0000 |
---|---|---|
committer | Tiago Botelho <tiagonbotelho@hotmail.com> | 2017-02-28 22:15:40 +0000 |
commit | 9f2e4742e354f5548b4956060f1bfa5ee3bd6657 (patch) | |
tree | 45067268ebbcfb48d51c627ef13c2820cad2ad1f /app/models/personal_access_token.rb | |
parent | f0ea7130f7bf0e7a3702d863b4d246f524b6c14a (diff) | |
download | gitlab-ce-9f2e4742e354f5548b4956060f1bfa5ee3bd6657.tar.gz |
applies relevant changes to the code and code structure
Diffstat (limited to 'app/models/personal_access_token.rb')
-rw-r--r-- | app/models/personal_access_token.rb | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/app/models/personal_access_token.rb b/app/models/personal_access_token.rb index cf94b01c33e..676e0832d54 100644 --- a/app/models/personal_access_token.rb +++ b/app/models/personal_access_token.rb @@ -7,20 +7,13 @@ class PersonalAccessToken < ActiveRecord::Base belongs_to :user + before_save :ensure_token + default_scope { where(impersonation: false) } scope :active, -> { where(revoked: false).where("expires_at >= NOW() OR expires_at IS NULL") } scope :inactive, -> { where("revoked = true OR expires_at < NOW()") } - scope :impersonation, -> { where(impersonation: true) } - - class << self - alias_method :and_impersonation_tokens, :unscoped - - def generate(params) - personal_access_token = self.new(params) - personal_access_token.ensure_token - personal_access_token - end - end + scope :impersonation, -> { unscoped.where(impersonation: true) } + scope :with_impersonation_tokens, -> { unscoped } def revoke! self.revoked = true |