summaryrefslogtreecommitdiff
path: root/app/models/concerns/token_authenticatable_strategies
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-11-27 14:34:05 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-11-27 14:34:05 +0100
commit37add27a00d38e4edaaec945ed9f44a123523884 (patch)
tree4d034575e8c6ee6019125ed820309989c25106ea /app/models/concerns/token_authenticatable_strategies
parent3dfbfa4e4f2ce962660dc534ac7a8c670049b506 (diff)
downloadgitlab-ce-37add27a00d38e4edaaec945ed9f44a123523884.tar.gz
Improve token authenticable tests and exceptions
Diffstat (limited to 'app/models/concerns/token_authenticatable_strategies')
-rw-r--r--app/models/concerns/token_authenticatable_strategies/base.rb8
-rw-r--r--app/models/concerns/token_authenticatable_strategies/encrypted.rb2
2 files changed, 5 insertions, 5 deletions
diff --git a/app/models/concerns/token_authenticatable_strategies/base.rb b/app/models/concerns/token_authenticatable_strategies/base.rb
index 23ee34962c7..4c63c0dd629 100644
--- a/app/models/concerns/token_authenticatable_strategies/base.rb
+++ b/app/models/concerns/token_authenticatable_strategies/base.rb
@@ -47,17 +47,17 @@ module TokenAuthenticatableStrategies
options[:fallback] == true
end
- def self.fabricate(instance, field, options)
+ def self.fabricate(model, field, options)
if options[:digest] && options[:encrypted]
raise ArgumentError, 'Incompatible options set!'
end
if options[:digest]
- TokenAuthenticatableStrategies::Digest.new(instance, field, options)
+ TokenAuthenticatableStrategies::Digest.new(model, field, options)
elsif options[:encrypted]
- TokenAuthenticatableStrategies::Encrypted.new(instance, field, options)
+ TokenAuthenticatableStrategies::Encrypted.new(model, field, options)
else
- TokenAuthenticatableStrategies::Insecure.new(instance, field, options)
+ TokenAuthenticatableStrategies::Insecure.new(model, field, options)
end
end
diff --git a/app/models/concerns/token_authenticatable_strategies/encrypted.rb b/app/models/concerns/token_authenticatable_strategies/encrypted.rb
index 8e052a3ef68..c23d78b050a 100644
--- a/app/models/concerns/token_authenticatable_strategies/encrypted.rb
+++ b/app/models/concerns/token_authenticatable_strategies/encrypted.rb
@@ -46,7 +46,7 @@ module TokenAuthenticatableStrategies
raise ArgumentError unless token.present?
instance[encrypted_field] = Gitlab::CryptoHelper.aes256_gcm_encrypt(token)
- instance[token_field] = nil
+ fallback_strategy.set_token(instance, nil) if fallback?
token
end