Sha256: 5199ddcbab3f2b81bca579cafe15ff31bc3aac6bc229d180f44db3b0fdba6059

Contents?: true

Size: 548 Bytes

Versions: 4

Compression:

Stored size: 548 Bytes

Contents

class Session < ApplicationRecord
  belongs_to :<%= singular_table_name %>

  before_create do
    self.user_agent = Current.user_agent
    self.ip_address = Current.ip_address
    self.sudo_at = Time.current
  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

4 entries across 4 versions & 1 rubygems

Version Path
authentication-zero-2.9.3 lib/generators/authentication/templates/models/session.rb.tt
authentication-zero-2.9.2 lib/generators/authentication/templates/models/session.rb.tt
authentication-zero-2.9.1 lib/generators/authentication/templates/models/session.rb.tt
authentication-zero-2.9.0 lib/generators/authentication/templates/models/session.rb.tt