Sha256: d1b5c51b7c468c0f58725b712eb37d56a256e1660ca9ee681ed071c31a58256a

Contents?: true

Size: 638 Bytes

Versions: 25

Compression:

Stored size: 638 Bytes

Contents

class Session < ApplicationRecord
  belongs_to :user
  <%- 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
    user.events.create! action: "signed_in"
  end

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

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
authentication-zero-2.12.4 lib/generators/authentication/templates/models/session.rb.tt
authentication-zero-2.12.3 lib/generators/authentication/templates/models/session.rb.tt
authentication-zero-2.12.2 lib/generators/authentication/templates/models/session.rb.tt
authentication-zero-2.12.1 lib/generators/authentication/templates/models/session.rb.tt
authentication-zero-2.12.0 lib/generators/authentication/templates/models/session.rb.tt