Class: Maquina::ActiveSession

Inherits:
ApplicationRecord show all
Defined in:
app/models/maquina/active_session.rb

Overview

A class representing the ActiveSession model in the Maquina module. Manages active user sessions and their expiration.

Attributes

  • maquina_user_id

    Foreign key reference to the associated User.

  • expires_at

    Timestamp when the session expires.

  • user_agent

    The user agent string from the client browser.

  • remote_addr

    The remote IP address of the client.

  • return_url

    URL to return to after session activities.

Associations

  • user

    Belongs to a User.

Validations

  • expires_at

    Must be present and in the future if session expiration is configured.

  • user

    Must not be blocked.

Callbacks

  • After initialize: Sets initial expiration time for new sessions based on configuration.

Delegations

  • blocked?

    Delegated to the associated user.

Instance Method Summary collapse

Methods inherited from ApplicationRecord

searchable?

Instance Method Details

#expired?Boolean

Checks if the session has expired

Returns:

  • true -> if expires_at is set and in the past

  • false -> if expires_at is not set or is in the future

Returns:

  • (Boolean)


47
48
49
50
51
# File 'app/models/maquina/active_session.rb', line 47

def expired?
  return false if expires_at.blank?

  !expires_at.future?
end