summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-03-27 17:01:24 -0700
committerRobert Speicher <rspeicher@gmail.com>2015-05-09 17:31:10 -0400
commitba7e2fd946ba94a9c0b3b18c3f7fc91f63fc652a (patch)
treeed6b4a7994d4d3daec1e1e441cd0a8ff246e842d /app/controllers
parent7302395142dc93a45239c993b69958ca4a757c92 (diff)
downloadgitlab-ce-ba7e2fd946ba94a9c0b3b18c3f7fc91f63fc652a.tar.gz
Create Two-factor authentication resource for user
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/profiles/two_factor_auths_controller.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/app/controllers/profiles/two_factor_auths_controller.rb b/app/controllers/profiles/two_factor_auths_controller.rb
new file mode 100644
index 00000000000..92ba842fac4
--- /dev/null
+++ b/app/controllers/profiles/two_factor_auths_controller.rb
@@ -0,0 +1,22 @@
+class Profiles::TwoFactorAuthsController < ApplicationController
+ def new
+ issuer = "GitLab | #{current_user.email}"
+ uri = current_user.otp_provisioning_uri(current_user.email, issuer: issuer)
+ @qr_code = RQRCode::render_qrcode(uri, :svg, level: :l, unit: 2)
+ end
+
+ def create
+ current_user.otp_required_for_login = true
+ current_user.otp_secret = User.generate_otp_secret
+ current_user.save!
+
+ redirect_to profile_account_path
+ end
+
+ def destroy
+ current_user.otp_required_for_login = false
+ current_user.save!
+
+ redirect_to profile_account_path
+ end
+end