Lanbo
Lanbo

Reputation: 15692

Persona automatically logs me out right after login

Well, this is my persona setup:

$ ->
    $('#login-btn').click (e) ->
        e.preventDefault()
        navigator.id.request()
        false
    $('#logout-btn').click (e) ->
        e.preventDefault()
        navigator.id.logout()
        false

    current_user = window.current_user or null

    navigator.id.watch
        loggedInUser: current_user
        onlogin: (assertion) ->
            ($.post '/verify', assertion: assertion, (response) ->
                if response.success
                    window.location.reload()
                else
                    console.log response
            ).fail (err) -> console.log err
        onlogout: () ->
            $.post '/logout', () ->
                window.location.reload()

The /verify and /logout paths just initialise the session. It works fine, the user is added to the database, which means the login is successful. I get to see the logged in screen for a moment, but then suddenly, the site reloads and I am logged out again. Every time.

During that brief moment, I was able to cancel the reload and could see that the email in window.current_user was correctly set as well.

So why does this happen?

Upvotes: 0

Views: 104

Answers (1)

djc
djc

Reputation: 11711

Do you happen to have disabled third-party cookies, by any chance?

Upvotes: 0

Related Questions