docs: add quixzoom-auth-core product to AAMOS
- Product documentation in docs/products/ - Updated MEMORY.md with product info - quiXzoom Auth Core as AAMOS Identity product
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* quiXzoom Site Auth Snippet
|
||||
* Include this on every quixzoom page for automatic auth
|
||||
*
|
||||
* Usage: Add to <head> of each HTML page:
|
||||
* <script type="module" src="/auth-check.js"></script>
|
||||
*/
|
||||
|
||||
import { quixzoomAuth } from 'https://auth.quixzoom.com/sso-client.js';
|
||||
|
||||
// Auto-check auth on page load
|
||||
(async function() {
|
||||
const user = await quixzoomAuth.init();
|
||||
|
||||
// Update UI based on auth state
|
||||
updateAuthUI(user);
|
||||
|
||||
// Listen for auth state changes
|
||||
document.addEventListener('quixzoom:auth', (e) => {
|
||||
updateAuthUI(e.detail.user);
|
||||
});
|
||||
})();
|
||||
|
||||
function updateAuthUI(user) {
|
||||
// Find auth elements
|
||||
const authElements = document.querySelectorAll('[data-auth]');
|
||||
|
||||
authElements.forEach(el => {
|
||||
const showWhen = el.dataset.auth; // 'logged-in' or 'logged-out'
|
||||
const isLoggedIn = user !== null;
|
||||
|
||||
if (showWhen === 'logged-in') {
|
||||
el.style.display = isLoggedIn ? '' : 'none';
|
||||
|
||||
// Update user info
|
||||
if (isLoggedIn && el.dataset.authName) {
|
||||
const nameEl = el.querySelector('[data-auth-user-name]');
|
||||
if (nameEl) {
|
||||
nameEl.textContent = `${user.first_name || ''} ${user.last_name || ''}`.trim() || user.email;
|
||||
}
|
||||
}
|
||||
} else if (showWhen === 'logged-out') {
|
||||
el.style.display = isLoggedIn ? 'none' : '';
|
||||
}
|
||||
});
|
||||
|
||||
// Update login links to include redirect
|
||||
document.querySelectorAll('a[href*="auth.quixzoom.com/login"]').forEach(link => {
|
||||
const url = new URL(link.href);
|
||||
url.searchParams.set('redirect', window.location.href);
|
||||
link.href = url.toString();
|
||||
});
|
||||
}
|
||||
|
||||
// Global logout function
|
||||
window.quixzoomLogout = async () => {
|
||||
await quixzoomAuth.logout();
|
||||
window.location.reload();
|
||||
};
|
||||
Reference in New Issue
Block a user