Sha256: d15982ca4aa708379abb818c6ca2b64d89eec0856acf89228692d0978187e685

Contents?: true

Size: 790 Bytes

Versions: 5

Compression:

Stored size: 790 Bytes

Contents

# frozen_string_literal: true

module Masks
  # @visibility private
  class BackupCodesController < ApplicationController
    require_mask type: :session, only: :new
    before_action only: %i[create] do
      require_sudo(backup_codes_path)
    end

    def new
      respond_to { |format| format.html { render(:new) } }
    end

    def create
      if create_params[:reset]
        @actor.saved_backup_codes_at = nil
        @actor.backup_codes = nil
        @actor.save
      elsif create_params[:enable]
        @actor.saved_backup_codes_at = Time.current
        @actor.save
      end

      respond_to { |format| format.html { redirect_to backup_codes_path } }
    end

    private

    def create_params
      params.require(:backup_codes).permit(:reset, :enable)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
masks-0.4.0 app/controllers/masks/backup_codes_controller.rb
masks-0.3.2 app/controllers/masks/backup_codes_controller.rb
masks-0.3.1 app/controllers/masks/backup_codes_controller.rb
masks-0.3.0 app/controllers/masks/backup_codes_controller.rb
masks-0.2.0 app/controllers/masks/backup_codes_controller.rb