Fix to QuickConnect

This commit is contained in:
Jimi 2024-01-13 10:00:29 -07:00 committed by Charles Ewert
parent 5db1b48f96
commit 6c9b3f10b5
3 changed files with 18 additions and 17 deletions

View File

@ -10,8 +10,16 @@ sub monitorQuickConnect()
authenticated = checkQuickConnect(m.top.secret) authenticated = checkQuickConnect(m.top.secret)
if authenticated = true if authenticated = true
m.top.authenticated = 1 loggedIn = AuthenticateViaQuickConnect(m.top.secret)
else if loggedIn
m.top.authenticated = -1 currentUser = AboutMe()
session.user.Login(currentUser, m.top.saveCredentials)
session.user.LoadUserPreferences()
LoadUserAbilities()
m.top.authenticated = 1
return
end if
end if end if
m.top.authenticated = -1
end sub end sub

View File

@ -4,5 +4,6 @@
<interface> <interface>
<field id="secret" type="string" /> <field id="secret" type="string" />
<field id="authenticated" type="integer" value="0" /> <field id="authenticated" type="integer" value="0" />
<field id="saveCredentials" type="boolean" />
</interface> </interface>
</component> </component>

View File

@ -14,11 +14,13 @@ sub quickConnectStatus()
m.quickConnectTimer.control = "stop" m.quickConnectTimer.control = "stop"
m.checkTask = CreateObject("roSGNode", "QuickConnect") m.checkTask = CreateObject("roSGNode", "QuickConnect")
m.checkTask.secret = m.top.quickConnectJson.secret m.checkTask.secret = m.top.quickConnectJson.secret
m.checkTask.saveCredentials = m.top.saveCredentials
m.checkTask.observeField("authenticated", "OnAuthenticated") m.checkTask.observeField("authenticated", "OnAuthenticated")
m.checkTask.control = "run" m.checkTask.control = "run"
end sub end sub
sub OnAuthenticated() sub OnAuthenticated()
m.checkTask.control = "stop"
m.checkTask.unobserveField("authenticated") m.checkTask.unobserveField("authenticated")
' Did we get the A-OK to authenticate? ' Did we get the A-OK to authenticate?
@ -26,28 +28,18 @@ sub OnAuthenticated()
if authenticated < 0 if authenticated < 0
' Still waiting, check again in 3 seconds... ' Still waiting, check again in 3 seconds...
authenticated = 0 authenticated = 0
m.checkTask.observeField("authenticated", "OnAuthenticated")
m.quickConnectTimer.control = "start" m.quickConnectTimer.control = "start"
else if authenticated > 0 else if authenticated > 0
' We've been given the go ahead, try to authenticate via Quick Connect... ' We've been logged in via Quick Connect...
authenticated = AuthenticateViaQuickConnect(m.top.quickConnectJson.secret) m.top.close = true
if authenticated <> invalid and authenticated = true m.top.authenticated = true
currentUser = AboutMe()
session.user.Login(currentUser, m.top.saveCredentials)
session.user.LoadUserPreferences()
LoadUserAbilities()
m.top.close = true
m.top.authenticated = true
else
m.top.close = true
m.top.authenticated = false
end if
end if end if
end sub end sub
sub quickConnectClosed() sub quickConnectClosed()
m.quickConnectTimer.control = "stop" m.quickConnectTimer.control = "stop"
if m.checkTask <> invalid if m.checkTask <> invalid
m.checkTask.control = "stop"
m.checkTask.unobserveField("authenticated") m.checkTask.unobserveField("authenticated")
end if end if
m.top.close = true m.top.close = true