Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I configure a simple login? #55

Open
Beor18 opened this issue Dec 9, 2020 · 12 comments
Open

How do I configure a simple login? #55

Beor18 opened this issue Dec 9, 2020 · 12 comments

Comments

@Beor18
Copy link

Beor18 commented Dec 9, 2020

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

@RokuChris
Copy link
Contributor

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})

@Beor18
Copy link
Author

Beor18 commented Dec 11, 2020

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

@RokuChris
Copy link
Contributor

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

@Beor18
Copy link
Author

Beor18 commented Dec 16, 2020

thanks you!

@Allan-Nava
Copy link

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

image

@Allan-Nava
Copy link

It is possible to create a custom task for login?

@RokuChris
Copy link
Contributor

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

@Allan-Nava
Copy link

I try now, thanks for the answer :)

@Allan-Nava
Copy link

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

@RokuChris
Copy link
Contributor

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

@Allan-Nava
Copy link

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

@Allan-Nava
Copy link

Allan-Nava commented Jul 28, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants