summaryrefslogtreecommitdiffstats
path: root/app/models/user.rb
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2020-08-29 06:21:50 +0000
committerGo MAEDA <maeda@farend.jp>2020-08-29 06:21:50 +0000
commit560bca344ae467cda03e758159fbf131d5c49f43 (patch)
tree15b4b2ec74c1d98e28f47453093588b271e18865 /app/models/user.rb
parent657ddfef452b145bbbce2970369ce42624dfca8e (diff)
downloadredmine-560bca344ae467cda03e758159fbf131d5c49f43.tar.gz
redmine-560bca344ae467cda03e758159fbf131d5c49f43.zip
Adds two factor authentication support (#1237).
Patch by Felix Schäfer. git-svn-id: http://svn.redmine.org/redmine/trunk@19988 e93f8b46-1217-0410-a6f0-8f06a7374b81
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?