1

I'm using Parse Server + Parse JS Sdk to handle user login through Facebook. Everything works fine until I refresh web browser. What data should I store after login process is done? I belive that FB AccessToken is important to keep Facebook Session, but what about Parse Session.

Current code:

login: function (callback) {
  console.log('loggin in...')
  Parse.FacebookUtils.logIn('user_likes,email', {
    success: function (parseUser) {
      if (!parseUser.existed()) {
        console.log('signed up and logged in!')
      } else {
        console.log('logged in!')
      }
      console.log('parse user is: ', parseUser.id)
      if (callback) { callback() }
    },
    error: function (parseUser, error) {
      console.log('login cancelled: ', error.message)
    }
  })
}

1 Answer 1

1

You don't need to manually store anything. You can use the parse function:

Parse.User.current()

To see if there is already a user logged-in.

We made this function:

function userAuthenticated(){
    if(Parse.User.current() === null){
        return false;
    }

    if(Parse.User.current().authenticated()){
        return true;
    }
    else{
        return false
    }
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for quick response! As soon as I will have access to my code I will check if it's working and mark answer as accepted :) Maybe someone else would have the same issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.