Sha256: fcec93101c9dfe7be821745447065b9bc1a9fed8d02f1221d30fe4885451251d

Contents?: true

Size: 487 Bytes

Versions: 2

Compression:

Stored size: 487 Bytes

Contents

class Session < ApplicationRecord
  belongs_to :user

  before_create do
    self.user_agent = Current.user_agent
    self.ip_address = Current.ip_address
    <%- if sudoable? %>
    self.sudo_at = Time.current
    <%- end -%>
  end
  <%- if options.trackable? %>
  after_create  { user.events.create! action: "signed_in" }
  after_destroy { user.events.create! action: "signed_out" }
  <%- end -%>
  <%- if sudoable? %>

  def sudo?
    sudo_at > 30.minutes.ago
  end
  <%- end -%>
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
authentication-zero-4.0.3 lib/generators/authentication/templates/models/session.rb.tt
authentication-zero-4.0.2 lib/generators/authentication/templates/models/session.rb.tt