Files
app
assets
controllers
admin
api
auth
concerns
oauth
settings
exports_controller.rb
imports_controller.rb
preferences_controller.rb
profiles_controller.rb
two_factor_auths_controller.rb
about_controller.rb
accounts_controller.rb
api_controller.rb
application_controller.rb
authorize_follow_controller.rb
home_controller.rb
media_controller.rb
remote_follow_controller.rb
statuses_controller.rb
stream_entries_controller.rb
tags_controller.rb
xrd_controller.rb
helpers
lib
mailers
models
services
views
workers
bin
config
db
docs
lib
log
public
spec
storybook
streaming
vendor
.babelrc
.buildpacks
.codeclimate.yml
.dockerignore
.env.production.sample
.env.test
.env.vagrant
.eslintrc
.gitignore
.nvmrc
.rspec
.rubocop.yml
.ruby-version
.slugignore
.travis.yml
CONTRIBUTING.md
Capfile
Dockerfile
Gemfile
Gemfile.lock
ISSUE_TEMPLATE.md
LICENSE
Procfile
README.md
Rakefile
Vagrantfile
app.json
config.ru
docker-compose.yml
package.json
scalingo.json
yarn.lock
hometown/app/controllers/settings/two_factor_auths_controller.rb
2017-02-13 20:56:03 +01:00

30 lines
734 B
Ruby

# frozen_string_literal: true
class Settings::TwoFactorAuthsController < ApplicationController
layout 'admin'
before_action :authenticate_user!
def show
return unless current_user.otp_required_for_login
@provision_url = current_user.otp_provisioning_uri(current_user.email, issuer: Rails.configuration.x.local_domain)
@qrcode = RQRCode::QRCode.new(@provision_url)
end
def enable
current_user.otp_required_for_login = true
current_user.otp_secret = User.generate_otp_secret
current_user.save!
redirect_to settings_two_factor_auth_path
end
def disable
current_user.otp_required_for_login = false
current_user.save!
redirect_to settings_two_factor_auth_path
end
end