Sha256: 9dd84650ac1e5668d380db93fed3ed32269c65a133a84ef7021ad7abb506aacf

Contents?: true

Size: 1.02 KB

Versions: 5

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

module Masks
  # @visibility private
  class RecoveriesController < ApplicationController
    before_action :redirect_if_logged_in, only: %i[new]

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

    def create
      flash[:recovery] = true

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

    def password
      @recovery = masked_session.extra(:recovery)

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

    def reset
      @recovery = masked_session.extra(:recovery)

      flash[:reset] = true if @recovery&.destroyed?
      flash[:errors] = @recovery.errors.full_messages if @recovery &&
        !@recovery&.valid?

      redirect =
        @recovery ? recover_password_path(token: @recovery.token) : recover_path

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

    private

    def redirect_if_logged_in
      redirect_to Masks.configuration.site_links[:root] if current_actor
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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