Untitled

mail@pastecode.io avatar
unknown
javascript
a month ago
822 B
2
Indexable
Never
 gigya.accounts.getAccountInfo({
   regToken : state.savedRegToken,
   include : 'loginIDs , emails, profile, data, userInfo, preferences',
   callback : response => handleLogin(response)
 })

function handleLogin(loginData) {
  let url = `${window.location.origin}${config.webservices.account.loginUrl}`
  popin.hide()

  if (isLoginPage) { // variable to define 
    showGlobalLoader() //reuse it 
    const form = document.createElement('form')
    form.action = url
    form.method = 'POST'
    form.className = 'is-hidden'

    Object.keys(loginData).forEach(key => {
      form.insertAdjacentHTML('beforeend', `<input type="hidden" name="${key}" value="${loginData[key]}"/>`)
    })
    document.body.appendChild(form)

    form.submit()
  }else {//checkout case
     Manager.publish('gigyaLogin', {loginData})
  }
}
Leave a Comment