Sha256: 42e2ff7efb5cf24b1928bee93afeb3fe2f10a46a4f231b8e50a311f0fe5dad8a

Contents?: true

Size: 1.23 KB

Versions: 2

Compression:

Stored size: 1.23 KB

Contents

# frozen-string-literal: true

module Rodauth
  Login = Feature.define(:login) do
    notice_flash "You have been logged in"
    error_flash "There was an error logging in"
    view 'login', 'Login'
    additional_form_tags
    button 'Login'
    redirect

    auth_value_method :login_form_footer, ''

    route do |r|
      check_already_logged_in
      before_login_route

      r.get do
        login_view
      end

      r.post do
        clear_session

        catch_error do
          unless account_from_login(param(login_param))
            throw_error(login_param, no_matching_login_message)
          end

          before_login_attempt

          unless open_account?
            throw_error(login_param, unverified_account_message)
          end

          unless password_match?(param(password_param))
            after_login_failure
            throw_error(password_param, invalid_password_message)
          end

          transaction do
            before_login
            update_session
            after_login
          end
          set_notice_flash login_notice_flash
          redirect login_redirect
        end

        set_error_flash login_error_flash
        login_view
      end
    end

    attr_reader :login_form_header
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rodauth-1.7.0 lib/rodauth/features/login.rb
rodauth-1.6.0 lib/rodauth/features/login.rb