Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-03-28 03:01:24 +0300
committerRobert Speicher <rspeicher@gmail.com>2015-05-10 00:31:10 +0300
commitba7e2fd946ba94a9c0b3b18c3f7fc91f63fc652a (patch)
treeed6b4a7994d4d3daec1e1e441cd0a8ff246e842d /app/controllers/profiles
parent7302395142dc93a45239c993b69958ca4a757c92 (diff)
Create Two-factor authentication resource for user
Diffstat (limited to 'app/controllers/profiles')
-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