|
107 | 107 | ' push all users to the user select view |
108 | 108 | userSelected = CreateUserSelectGroup(publicUsersNodes) |
109 | 109 | SendPerformanceBeacon("AppDialogComplete") ' Roku Performance monitoring - Dialog Closed |
110 | | - if userSelected = "backPressed" |
| 110 | + if userSelected = "quickConnect" |
| 111 | + ' Quick Connect completed the sign-in in-flow. user state (id, authToken, |
| 112 | + ' and optionally registry creds based on the post-auth prompt) is already |
| 113 | + ' populated on m.global.user, so skip the token/password ladder entirely. |
| 114 | + m.global.sceneManager.callFunc("clearScenes") |
| 115 | + return true |
| 116 | + else if userSelected = "backPressed" |
111 | 117 | ' User wants to change server - clear all scenes and restart |
112 | 118 | server.Delete() |
113 | 119 | unsetSetting("server") |
|
451 | 457 | group.observeField("backPressed", port) |
452 | 458 | while true |
453 | 459 | msg = wait(0, port) |
454 | | - ' print "roSGNodeEvent: msg.getNode() =", msg.getNode() |
455 | | - ' print "roSGNodeEvent: msg.getData() =", msg.getData() |
456 | | - ' print "roSGNodeEvent: msg.getField() =", msg.getField() |
457 | | - ' print "roSGNodeEvent: msg.getRoSGNode() =", msg.getRoSGNode() |
458 | | - ' print "roSGNodeEvent: msg.getInfo() =", msg.getInfo() |
459 | 460 | if type(msg) = "roSGScreenEvent" and msg.isScreenClosed() |
460 | 461 | group.visible = false |
461 | 462 | return -1 |
|
465 | 466 | else if type(msg) = "roSGNodeEvent" and msg.getField() = "userSelected" |
466 | 467 | return msg.GetData() |
467 | 468 | else if type(msg) = "roSGNodeEvent" and msg.getField() = "buttonSelected" |
468 | | - ' Manual Login button pressed |
469 | | - if msg.getData() = 0 ' button index |
| 469 | + buttonGroup = msg.getRoSGNode() |
| 470 | + buttonSelected = buttonGroup.getChild(msg.getData()) |
| 471 | + if buttonSelected.id = "manualLoginButton" |
470 | 472 | return "" |
| 473 | + else if buttonSelected.id = "quickConnect" |
| 474 | + json = initQuickConnect() |
| 475 | + if not isValid(json) |
| 476 | + m.global.sceneManager.callFunc("userMessage", translate(translationKeys.ButtonQuickConnect), translate(translationKeys.LabelQuickConnectNotAvailable)) |
| 477 | + else |
| 478 | + ' Server supports Quick Connect - show the code, then the dialog transforms |
| 479 | + ' into a "Save credentials?" prompt on auth success. |
| 480 | + m.quickConnectDialog = createObject("roSGNode", "QuickConnectDialog") |
| 481 | + m.quickConnectDialog.quickConnectJson = json |
| 482 | + m.quickConnectDialog.title = translate(translationKeys.ButtonQuickConnect) |
| 483 | + m.quickConnectDialog.message = [translate(translationKeys.MessageHereIsYourQuickConnectCode, [json.Code])] |
| 484 | + m.quickConnectDialog.buttons = [translate(translationKeys.ButtonCancel)] |
| 485 | + m.quickConnectDialog.observeField("isAuthenticated", port) |
| 486 | + m.scene.dialog = m.quickConnectDialog |
| 487 | + end if |
471 | 488 | end if |
| 489 | + else if type(msg) = "roSGNodeEvent" and msg.getField() = "isAuthenticated" |
| 490 | + ' QuickConnectDialog only ever fires this with value=true (after the |
| 491 | + ' user has answered the post-auth save-credentials prompt). |
| 492 | + return "quickConnect" |
472 | 493 | end if |
473 | 494 | end while |
474 | 495 |
|
|
510 | 531 | saveCheckBox.title = translate(translationKeys.MessageSaveCredentials) |
511 | 532 | items.appendChild(saveCheckBox) |
512 | 533 | checkbox.content = items |
513 | | - quickConnect = group.findNode("quickConnect") |
514 | | - ' Quick Connect only supported for server version 10.8+ right now... |
515 | | - if versionChecker(m.global.server.version, "10.8.0") |
516 | | - ' Add option for Quick Connect |
517 | | - quickConnect.text = translate(translationKeys.ButtonQuickConnect) |
518 | | - quickConnect.observeField("buttonSelected", port) |
519 | | - else |
520 | | - quickConnect.visible = false |
521 | | - end if |
522 | 534 |
|
523 | 535 | items = [usernameField, passwordField] |
524 | 536 | config.configItems = items |
|
576 | 588 | stopLoadingSpinner() |
577 | 589 | print "Login attempt failed..." |
578 | 590 | group.findNode("alert").text = translate(translationKeys.ErrorLoginAttemptFailed) |
579 | | - else if buttonSelected.id = "quickConnect" |
580 | | - json = initQuickConnect() |
581 | | - if not isValid(json) |
582 | | - group.findNode("alert").text = translate(translationKeys.LabelQuickConnectNotAvailable) |
583 | | - else |
584 | | - ' Server user is talking to is at least 10.8 and has quick connect enabled... |
585 | | - m.quickConnectDialog = createObject("roSGNode", "QuickConnectDialog") |
586 | | - m.quickConnectDialog.shouldSaveCredentials = checkbox.checkedState[0] |
587 | | - m.quickConnectDialog.quickConnectJson = json |
588 | | - m.quickConnectDialog.title = translate(translationKeys.ButtonQuickConnect) |
589 | | - m.quickConnectDialog.message = [translate(translationKeys.MessageHereIsYourQuickConnectCode, [json.Code]), translate(translationKeys.LabelDialogWillCloseAutomatically)] |
590 | | - m.quickConnectDialog.buttons = [translate(translationKeys.ButtonCancel)] |
591 | | - m.quickConnectDialog.observeField("isAuthenticated", port) |
592 | | - m.scene.dialog = m.quickConnectDialog |
593 | | - end if |
594 | | - end if |
595 | | - |
596 | | - if msg.getField() = "isAuthenticated" |
597 | | - authenticated = msg.getData() |
598 | | - if authenticated = true |
599 | | - ' Quick connect authentication was successful... |
600 | | - return "true" |
601 | | - else |
602 | | - dialog = createObject("roSGNode", "Dialog") |
603 | | - dialog.id = "QuickConnectError" |
604 | | - dialog.title = translate(translationKeys.ButtonQuickConnect) |
605 | | - dialog.buttons = [translate(translationKeys.ButtonOk)] |
606 | | - dialog.message = translate(translationKeys.ErrorThereWasAnErrorAuthenticatingVia) |
607 | | - m.scene.dialog = dialog |
608 | | - m.scene.dialog.observeField("buttonSelected", port) |
609 | | - end if |
610 | | - else |
611 | | - ' If there are no other button matches, check if this is a simple "OK" Dialog & Close if so |
612 | | - dialog = msg.getRoSGNode() |
613 | | - if dialog.id = "QuickConnectError" |
614 | | - dialog.unobserveField("buttonSelected") |
615 | | - dialog.close = true |
616 | | - end if |
617 | 591 | end if |
618 | 592 | end if |
619 | 593 | end if |
|
0 commit comments