Sha256: 0eaf7de376f3d84b7beb01469883f40f24a2e6f0c49db4768a6b9fa1956eb642

Contents?: true

Size: 1.21 KB

Versions: 8

Compression:

Stored size: 1.21 KB

Contents

# frozen-string-literal: true

module Rodauth
  ConfirmPassword = Feature.define(:confirm_password) do
    notice_flash "Your password has been confirmed"
    error_flash "There was an error confirming your password"
    view 'confirm-password', 'Confirm Password'
    additional_form_tags
    button 'Confirm Password'
    before
    after

    auth_value_methods :confirm_password_redirect

    auth_methods :confirm_password

    route do
      require_account
      before_confirm_password_route

      request.get do
        confirm_password_view
      end

      request.post do
        if password_match?(param(password_param))
          transaction do
            before_confirm_password
            confirm_password
            after_confirm_password
          end
          set_notice_flash confirm_password_notice_flash
          redirect confirm_password_redirect
        else
          set_field_error(password_param, invalid_password_message)
          set_error_flash confirm_password_error_flash
          confirm_password_view
        end
      end
    end

    def confirm_password
      nil
    end

    def confirm_password_redirect
      session.delete(:confirm_password_redirect) || default_redirect
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rodauth-1.7.0 lib/rodauth/features/confirm_password.rb
rodauth-1.6.0 lib/rodauth/features/confirm_password.rb
rodauth-1.5.0 lib/rodauth/features/confirm_password.rb
rodauth-1.4.0 lib/rodauth/features/confirm_password.rb
rodauth-1.3.0 lib/rodauth/features/confirm_password.rb
rodauth-1.2.0 lib/rodauth/features/confirm_password.rb
rodauth-1.1.0 lib/rodauth/features/confirm_password.rb
rodauth-1.0.0 lib/rodauth/features/confirm_password.rb