Skip to content

Commit

Permalink
Handle invalid stored myPlex tokens.
Browse files Browse the repository at this point in the history
User has an option to `Sign In` or `Ignore` the prompt.

fixes plexinc/roku-client#210
  • Loading branch information
ljunkie committed Jan 28, 2015
1 parent a552b1d commit 27c8691
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
15 changes: 15 additions & 0 deletions Plex/source/MyPlexManager.brs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,16 @@ Sub mpProcessAccountResponse(event)
Debug("Failed to validate myPlex token: ResponseCode=" + responseCode)
if val(responseCode) >= 400 and val(responseCode) < 500 then
m.Disconnect()

' Set the reauth flag and a dialog to continue or cancel reauth
MyPlexManager().reauth = true
dlg = createBaseDialog()
dlg.Title = "Please sign in again. Your credentials have expired."
dlg.Text = " "
dlg.SetButton("sign_in", "Sign In")
dlg.SetButton("ignore", "Ignore")
dlg.HandleButton = mpDialogHandleButton
dlg.Show(true)
else
m.SetOffline()
end if
Expand Down Expand Up @@ -484,3 +494,8 @@ sub mpSetOffline()
' reset registry user
RegInitializeUser()
end sub

Function mpDialogHandleButton(command, data) As Boolean
if command <> "sign_in" then MyPlexManager().reauth = false
return true
End Function
2 changes: 1 addition & 1 deletion Plex/source/MyPlexPinScreen.brs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Function createMyPlexPinScreen(viewController As Object) As Object
screen.AddParagraph("This screen will automatically update once your Roku player has been linked to your Plex account.")

screen.AddButton(0, "get a new code")
screen.AddButton(1, "back")
screen.AddButton(1, "cancel")

' Set standard screen properties/methods
obj.Screen = screen
Expand Down
9 changes: 9 additions & 0 deletions Plex/source/ViewController.brs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ Function GetViewController()
End Function

Function vcCreateHomeScreen() as dynamic
' Show the PIN screen if we have been flagged for reauth
if MyPlexManager().reauth = true then
MyPlexManager().reauth = false
screen = createMyPlexPinScreen(m)
m.InitializeOtherScreen(screen, invalid)
screen.Show()
return invalid
end if

' show the user list on startup for multi-user homes or if the last user is protected
isProtectedUser = (MyPlexManager().Protected = true and NOT(MyPlexManager().PinAuthenticated = true))
isMultiUserHome = (MyPlexManager().homeUsers.count() > 1)
Expand Down

0 comments on commit 27c8691

Please sign in to comment.