Managing cloud users

I am trying to implement the session login for my game. I am using storyboard, so I in my enterScene() function I am passing the params as suggested by the doc.

[lua]

local loginParams = {}

loginParams.type = “session”

loginParams.authToken = box.token

cloud.login( loginParams )

[/lua]

It is not working for me though, I am saving the auth token and printing to the console, so I know it is right. When I hard code some login details and call it from the same place it works fine, so I dont know why the session login is not working. Here is the authListener from my code

[lua]

local authListener = function( event )

    – all events contain event.name, event.type, event.error, event.response.

        if event.type == “loggedIn” or event.type == “sessionLoggedIn” then

            if not (event.error) then

                print( "User is logged in: ", cloud.isLoggedIn )

                – get the user profile

                currentAuthToken = cloud.authToken

                print(“logging in with current token”)

                print(currentAuthToken)

                box:set( “token”, currentAuthToken )

                box:save()

                print(“Box token”)

                print( box.token )

                cloud.getProfile()

                --cloud.getProfile(username)

            else

                native.showAlert( “Login Error!”, event.error, {“OK”} )

            end

        end

        if event.type == “registerUser”  then

            print(“registering user”)

            if not (event.error ) then

                --handle registration here

                toast.new("Created new profile: "…response.username, 3000)

            else

                native.showAlert( “Registration Error!”, event.error, {“OK”} )

            end

        end

        if event.type == “getProfile” then

            print( "The user profile: ", event.response )

            local response = event.response

            response = json.decode( event.response )

            print(response.username)

            --print(response.points)

            storyboard.points = response.points

            toast.new("Logged in as: "…response.username, 3000)

            storyboard.user = response.username

            storyboard.gotoScene( “player”, “crossFade”, 1000 )

            – textnew = display.newText(response.username, 20, 175, native.systemFont, 24)

            – textnew:setTextColor(255, 0 , 3)

        end

    end

[/lua]

Also I know I am registering new users correctly, because I can login and  they are being added to the leaderboard when I submit a new high score, but when I register a new user I never hit the if event.type == registerUser part of my authListener, so I am not getting error messages if a user registers incorrectly or successfully.

Any help would be really appreciated.

Gooner87

the session login never enters the authlistener. Me and some others went through the same thing in this discussion here which may help you abit:

http://forums.coronalabs.com/topic/34316-authtoken-session-login/

Why it dosent enter the registerUser bit when you register a new user I dont know, it should work at least.

Thanks borqb,

That explains the session login,  It really should be explained more clearly in the docs. Still can’t figure out why the registerUser event is not getting called though, has anyone else had this problem?

the session login never enters the authlistener. Me and some others went through the same thing in this discussion here which may help you abit:

http://forums.coronalabs.com/topic/34316-authtoken-session-login/

Why it dosent enter the registerUser bit when you register a new user I dont know, it should work at least.

Thanks borqb,

That explains the session login,  It really should be explained more clearly in the docs. Still can’t figure out why the registerUser event is not getting called though, has anyone else had this problem?