diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-11-27 14:34:05 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-11-27 14:34:05 +0100 |
commit | 37add27a00d38e4edaaec945ed9f44a123523884 (patch) | |
tree | 4d034575e8c6ee6019125ed820309989c25106ea /app/models/concerns/token_authenticatable_strategies | |
parent | 3dfbfa4e4f2ce962660dc534ac7a8c670049b506 (diff) | |
download | gitlab-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.rb | 8 | ||||
-rw-r--r-- | app/models/concerns/token_authenticatable_strategies/encrypted.rb | 2 |
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 |