@cocreate/users
Advanced tools
Comparing version 1.36.8 to 1.36.9
{ | ||
"name": "@cocreate/users", | ||
"version": "1.36.8", | ||
"version": "1.36.9", | ||
"description": "A simple users component in vanilla javascript. Easily configured using HTML5 attributes and/or JavaScript API.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -189,23 +189,27 @@ /*globals CustomEvent, btoa*/ | ||
let redirectTag | ||
if (data.userStatus == 'on' || data.userStatus == 'idle') { | ||
let redirectTag = document.querySelector('[session="true"]'); | ||
if (redirectTag) { | ||
let redirectLink = redirectTag.getAttribute('href'); | ||
if (redirectLink) { | ||
document.location.href = redirectLink; | ||
} | ||
} | ||
redirectTag = document.querySelector('[session="true"]'); | ||
} else if (data.userStatus == 'off') { | ||
let redirectTag = document.querySelector('[session="false"]'); | ||
redirectTag = document.querySelector('[session="false"]'); | ||
} | ||
if (redirectTag) { | ||
let redirectLink = redirectTag.getAttribute('href'); | ||
if (redirectLink) { | ||
if (redirectTag) { | ||
let redirectLink = redirectTag.getAttribute('href'); | ||
if (redirectLink) { | ||
if (data.userStatus == 'off') { | ||
localStorage.removeItem("user_id"); | ||
localStorage.removeItem("token"); | ||
document.location.href = redirectLink; | ||
} | ||
// Normalize both URLs to compare paths in a uniform way | ||
const currentPath = new URL(location.href).pathname.replace('/index.html', '/'); | ||
const targetPath = new URL(redirectLink, location.href).pathname.replace('/index.html', '/'); | ||
if (currentPath !== targetPath) { | ||
location.href = redirectLink; | ||
} | ||
} | ||
} | ||
@@ -212,0 +216,0 @@ |
Sorry, the diff of this file is too big to display
215405
920