rokudev / SceneGraphDeveloperExtensions

Other
114 stars 64 forks source link

How do I configure a simple login? #55

Open Beor18 opened 3 years ago

Beor18 commented 3 years ago

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

RokuChris commented 3 years ago

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 commented 3 years ago

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

RokuChris commented 3 years ago

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 commented 3 years ago

thanks you!

Allan-Nava commented 3 years ago

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

image

Allan-Nava commented 3 years ago

It is possible to create a custom task for login?

RokuChris commented 3 years ago

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 commented 3 years ago

I try now, thanks for the answer :)

Allan-Nava commented 3 years ago

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

RokuChris commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

I still have the same problem

Il giorno mar 27 lug 2021 alle ore 19:16 RokuChris @.***> ha scritto:

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

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rokudev/SceneGraphDeveloperExtensions/issues/55#issuecomment-887687809, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFLUZA3QZTSOMXRMFQMNSZLTZ3SVXANCNFSM4UUDA2VA .

--

Allan Nava direct: +39 340 94 77 141 @. @.>*