Skip to content

Instantly share code, notes, and snippets.

@raphaelchaib
Created August 6, 2015 00:45
Show Gist options
  • Save raphaelchaib/b8185255067efff29835 to your computer and use it in GitHub Desktop.
Save raphaelchaib/b8185255067efff29835 to your computer and use it in GitHub Desktop.
VTEX: User login functions
/**
* isVTEXUserIdentified
* Verifica se o usuário VTEX está identificado (quando o sistema identificou
* o usuário pelo e-mail, mas ele ainda não digitou sua senha).
*
* @return BOOL
* TRUE - Se se estiver identificado ou autenticado
* FALSE - Se não estiver identificado
*/
function isVTEXUserIdentified() {
return /VtexRC/.test(document.cookie);
}
/**
* isVTEXUserAuthenticated
* Verifica se o usuário VTEX está autenticado (quando o usuário
* já digitou sua senha).
*
* @return BOOL
* TRUE - Se se estiver autenticado
* FALSE - Se não estiver autenticado (isso não significa
* que ele não está identificado)
*/
function isVTEXUserAuthenticated() {
ret = false;
for(var i in dataLayer) {
for(var key in dataLayer[i]) {
if(key=='visitorLoginState' && dataLayer[i][key]===true) ret=true;
}
}
return ret;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment