Updates to help_customer helper
parent
b45f806309
commit
35ae847fe9
|
@ -46,9 +46,10 @@ class SessionToken < AbstractJwtToken
|
||||||
beta_os_update_server: BETA_OS_URL }])
|
beta_os_update_server: BETA_OS_URL }])
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.as_json(user, aud, fbos_version)
|
def self.as_json(user, aud, fbos_version, exp = EXPIRY.from_now.to_i)
|
||||||
{ token: SessionToken.issue_to(user, iss: $API_URL,
|
{ token: SessionToken.issue_to(user, iss: $API_URL,
|
||||||
aud: aud,
|
aud: aud,
|
||||||
|
exp: exp,
|
||||||
fbos_version: fbos_version),
|
fbos_version: fbos_version),
|
||||||
user: user }
|
user: user }
|
||||||
end
|
end
|
||||||
|
|
|
@ -166,8 +166,12 @@ class Device < ApplicationRecord
|
||||||
# Used by sys admins to debug problems without performing a password reset.
|
# Used by sys admins to debug problems without performing a password reset.
|
||||||
def help_customer
|
def help_customer
|
||||||
Rollbar.error("Someone is creating a debug user token", { device: self.id })
|
Rollbar.error("Someone is creating a debug user token", { device: self.id })
|
||||||
token = SessionToken.as_json(users.first, "staff", fbos_version).to_json
|
token = SessionToken.as_json(users.first,
|
||||||
return "localStorage['session'] = JSON.stringify(#{token});"
|
"staff",
|
||||||
|
fbos_version,
|
||||||
|
9.hours.from_now.to_i)
|
||||||
|
puts "localStorage['session'] = JSON.stringify(#{token.to_json});"
|
||||||
|
token
|
||||||
end
|
end
|
||||||
|
|
||||||
TOO_MANY_CONNECTIONS =
|
TOO_MANY_CONNECTIONS =
|
||||||
|
|
|
@ -5,8 +5,10 @@ describe Device do
|
||||||
let(:user) { device.users.first }
|
let(:user) { device.users.first }
|
||||||
|
|
||||||
it "creates a token" do
|
it "creates a token" do
|
||||||
jwt = device.help_customer
|
expect do
|
||||||
expect(jwt).to be_kind_of(String)
|
jwt = device.help_customer
|
||||||
|
expect(jwt[:token]).to be_kind_of(SessionToken)
|
||||||
|
end.to output(/localStorage\[\'session\'\]/).to_stdout
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is associated with a user" do
|
it "is associated with a user" do
|
||||||
|
|
Loading…
Reference in New Issue