Class: Masks::Credentials::Device
Overview
Checks for a known, valid :device.
If the device is not associated with the session’s actor, it will be. Identification is based on the user_agent
and a few other facets.
Instance Method Summary
collapse
#backup!, #check, checks, #cleanup!, #mask!, #name, #patch_params, #slug
Instance Method Details
#backup ⇒ Object
47
48
49
|
# File 'app/models/masks/credentials/device.rb', line 47
def backup
session.(:device)&.touch(:accessed_at) if session&.passed?
end
|
#cleanup ⇒ Object
51
52
53
54
55
56
|
# File 'app/models/masks/credentials/device.rb', line 51
def cleanup
device = session.(:device)
device&.reset_version
session.data[:device_key] = nil
end
|
#lookup ⇒ Object
12
13
14
15
16
17
18
19
20
|
# File 'app/models/masks/credentials/device.rb', line 12
def lookup
return unless actor
device = config.find_device(session, actor:)
session.(device:)
nil
end
|
#maskup ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'app/models/masks/credentials/device.rb', line 22
def maskup
device = session.(:device)
return deny! unless device
session_key = session.data[:device_key]
if session_key && device.session_key != session_key
raise "invalid device"
end
if device.known?
session.data[:device_key] = device.session_key
actor.devices << device
approve!
else
cleanup
deny!
end
end
|