rokudev/SceneGraphDeveloperExtensions

How do I configure a simple login?

Opened this issue ยท 12 comments

It would be nice to create a simple login example without much logic.

There are several code snippets in the EntitlementView documentation that show some of the simplest use cases. https://github.com/rokudev/SceneGraphDeveloperExtensions/blob/master/documentation/1-components.md#entitlementview

If you're interested in username/password authentication, this one is probably the most helpful...

ent = CreateObject("roSGNode", "EntitlementView")
ent.mode = "UserPass"
ent.ObserveField("isAuthenticated", "OnIsAuthenticated")
content = CreateObject("roSGNode", "ContentNode")
content.Update({
    handlerConfigEntitlement: {
        name: "myAuthHandler"
    }
}, true)
ent.content = content
m.top.ComponentController.callFunc("show", {view: ent})

yes, but I don't understand when it says create the view .. at that point, what would I have to create?

The view in this case is an SGDEX EntitlementView. It's created by this line of code...

ent = CreateObject("roSGNode", "EntitlementView")

The only other thing you need to do is build an EntitlementHandler similar to the one in the RokuPay sample. In that handler, you should define a function called Authenticate() that contains whatever auth logic you need for your particular channel. Once the user enters their credentials, SGDEX will pass them to that function.

function Authenticate(username as String, password as String) as Boolean

thanks you!

I have the same problem; I did the LoginView but now I need to go to main controller

image

It is possible to create a custom task for login?

Yes it is. Our recommendation would be to use EntitlementView and EntitlementHandler for authentication. But if those don't meet your requirements, you can certainly build whatever custom Tasks you need for your channel.

https://github.com/rokudev/SceneGraphDeveloperExtensions/blob/master/documentation/1-components.md#entitlementview

I try now, thanks for the answer :)

I got it! but if I want to logout and delete all stack of navigation what can I do? @RokuChris

Each view has close and wasClosed fields that you can set and observe respectively to manage the stack.

https://github.com/rokudev/SceneGraphDeveloperExtensions/blob/master/documentation/1-components.md#sgdexcomponent

somethings like this ?

function CloseAllScreens()
    ? "CloseAllScreens() "
    if m.loginView <> invalid
        ? "CloseAllScreens() m.loginView close = true"
        m.loginView = invalid
    endif 
    if m.accountView  <> invalid
        ? "CloseAllScreens() m.accountView close = true"
        m.accountView = invalid
    endif 
    if m.top.componentController <> invalid
        ? "CloseAllScreens() m.componentController close = true"
        'm.top.componentController.close = true 
    endif 
end function 
'

Cause after I logged out , I stil lhave the button bar stuff

telegram-cloud-photo-size-4-5766956179111655949-y