diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-11-15 18:08:28 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-11-15 18:08:28 +0300 |
commit | 3ee8e01923c9452afe9ae21c2135aa8a7eb82f89 (patch) | |
tree | 450fed992dbc62d38c2d4c607f40443faacaed89 /app/models/concerns/token_authenticatable_strategies/base.rb | |
parent | f1a74a656bcede06d082e351d6261e43a88a0df7 (diff) |
Extract token authenticatable strategy fabrication
Diffstat (limited to 'app/models/concerns/token_authenticatable_strategies/base.rb')
-rw-r--r-- | app/models/concerns/token_authenticatable_strategies/base.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/app/models/concerns/token_authenticatable_strategies/base.rb b/app/models/concerns/token_authenticatable_strategies/base.rb index 53b09ffd4d9..a722616756a 100644 --- a/app/models/concerns/token_authenticatable_strategies/base.rb +++ b/app/models/concerns/token_authenticatable_strategies/base.rb @@ -43,6 +43,16 @@ module TokenAuthenticatableStrategies options[:fallback] == true end + def self.fabricate(instance, field, options) + if options[:digest] + TokenAuthenticatableStrategies::Digest.new(instance, field, options) + elsif options[:encrypted] + TokenAuthenticatableStrategies::Encrypted.new(instance, field, options) + else + TokenAuthenticatableStrategies::Insecure.new(instance, field, options) + end + end + protected def write_new_token(instance) |