Sha256: 9a4184e4936467031f462ff7afd12799c3f0b85923582597d8dbbd17f5e72e46

Contents?: true

Size: 704 Bytes

Versions: 2

Compression:

Stored size: 704 Bytes

Contents

class Session < ApplicationRecord
  belongs_to :<%= singular_table_name %>
  <%- if options.sudoable? %>
  kredis_flag :sudo, expires_in: 30.minutes
  <%- end -%>

  before_create do
    self.user_agent = Current.user_agent
    self.ip_address = Current.ip_address
  end
  <%- if options.sudoable? %>
  after_create_commit do
    self.sudo.mark
  end
  <%- end -%>

  after_create_commit do
    SessionMailer.with(session: self).signed_in_notification.deliver_later
  end
  <%- if options.trackable? %>
  after_create do
    <%= singular_table_name %>.events.create! action: "signed_in"
  end

  after_destroy do
    <%= singular_table_name %>.events.create! action: "signed_out"
  end
  <%- end -%>
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
authentication-zero-2.11.2 lib/generators/authentication/templates/models/session.rb.tt
authentication-zero-2.11.1 lib/generators/authentication/templates/models/session.rb.tt