summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2015-06-19 14:59:42 -0400
committerRobert Speicher <rspeicher@gmail.com>2015-06-19 14:59:42 -0400
commit6c8f0fe906d76cf27f22ffcd3475084f6e0398ec (patch)
tree9f0b9e2675cbbc4884fc57473585cf504194f3ac /app/models
parent7964e7d6a1c77e470b93ca3cca69b03f506505ac (diff)
downloadgitlab-ce-6c8f0fe906d76cf27f22ffcd3475084f6e0398ec.tar.gz
Add convenience methods to User for getting and setting 2FA status
Diffstat (limited to 'app/models')
-rw-r--r--app/models/user.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index b075795d40b..a2e2d220b3a 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -300,6 +300,18 @@ class User < ActiveRecord::Base
@reset_token
end
+ # Check if the user has enabled Two-factor Authentication
+ def two_factor_enabled?
+ otp_required_for_login
+ end
+
+ # Set whether or not Two-factor Authentication is enabled for the current user
+ #
+ # setting - Boolean
+ def two_factor_enabled=(setting)
+ self.otp_required_for_login = setting
+ end
+
def namespace_uniq
namespace_name = self.username
existing_namespace = Namespace.by_path(namespace_name)