summaryrefslogtreecommitdiffstats
path: root/app/models/user.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/user.rb')
-rw-r--r--app/models/user.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 6c2adc141..5b4089ea4 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -20,6 +20,7 @@
require "digest/sha1"
class User < Principal
+ include Redmine::Ciphering
include Redmine::SafeAttributes
# Different ways of displaying/sorting users
@@ -391,6 +392,10 @@ class User < Principal
self
end
+ def twofa_active?
+ twofa_scheme.present?
+ end
+
def pref
self.preference ||= UserPreference.new(:user => self)
end
@@ -451,6 +456,14 @@ class User < Principal
Token.where(:user_id => id, :action => 'autologin', :value => value).delete_all
end
+ def twofa_totp_key
+ read_ciphered_attribute(:twofa_totp_key)
+ end
+
+ def twofa_totp_key=(key)
+ write_ciphered_attribute(:twofa_totp_key, key)
+ end
+
# Returns true if token is a valid session token for the user whose id is user_id
def self.verify_session_token(user_id, token)
return false if user_id.blank? || token.blank?