Class: QuoVadis::Session

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
IpMasking
Defined in:
app/models/quo_vadis/session.rb

Overview

A session is started once a user logs in with a password, regardless of whether 2FA is also required.

Instance Method Summary collapse

Methods included from IpMasking

included, #mask_ip

Instance Method Details

#authenticated_with_second_factorObject



20
21
22
# File 'app/models/quo_vadis/session.rb', line 20

def authenticated_with_second_factor
  touch :second_factor_at
end

#expired?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'app/models/quo_vadis/session.rb', line 32

def expired?
  exceeded_lifetime? || exceeded_idle_timeout?
end

#logout_other_sessionsObject



16
17
18
# File 'app/models/quo_vadis/session.rb', line 16

def logout_other_sessions
  .sessions.reject { |s| s == self }.each &:destroy
end

#replaceObject



36
37
38
# File 'app/models/quo_vadis/session.rb', line 36

def replace
  destroy.dup.tap &:save
end

#reset_authenticated_with_second_factorObject



24
25
26
# File 'app/models/quo_vadis/session.rb', line 24

def reset_authenticated_with_second_factor
  update second_factor_at: nil
end

#second_factor_authenticated?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'app/models/quo_vadis/session.rb', line 28

def second_factor_authenticated?
  !second_factor_at.nil?
end