Mark-Lasfar
commited on
Commit
·
e6afcc0
1
Parent(s):
b249bd4
Update authorize for google & github
Browse files- templates/login.html +90 -60
templates/login.html
CHANGED
|
@@ -9,17 +9,14 @@
|
|
| 9 |
<meta name="robots" content="index, follow">
|
| 10 |
<title>Login - MGZon Chatbot</title>
|
| 11 |
<!-- manifest for Android/Chrome -->
|
| 12 |
-
<link rel="manifest" href="/static/manifest.json">
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
<
|
| 16 |
-
<meta name="apple-mobile-web-app-
|
| 17 |
-
<meta name="apple-mobile-web-app-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
<!-- General Theme -->
|
| 21 |
-
<meta name="theme-color" content="#2d3748">
|
| 22 |
-
|
| 23 |
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
|
| 24 |
<!-- Open Graph -->
|
| 25 |
<meta property="og:title" content="Login - MGZon Chatbot">
|
|
@@ -33,21 +30,21 @@
|
|
| 33 |
<meta name="twitter:description" content="Login to MGZon Chatbot to access AI-powered code generation and e-commerce tools.">
|
| 34 |
<meta name="twitter:image" content="/static/images/mg.svg">
|
| 35 |
<!-- JSON-LD -->
|
| 36 |
-
<script type="application/ld+json">
|
| 37 |
-
{
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
|
|
|
| 48 |
}
|
| 49 |
-
|
| 50 |
-
</script>
|
| 51 |
<!-- Tailwind (v3) -->
|
| 52 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 53 |
<!-- Boxicons -->
|
|
@@ -107,12 +104,12 @@
|
|
| 107 |
</button>
|
| 108 |
</form>
|
| 109 |
<div class="flex justify-center gap-4 mt-4 flex-wrap">
|
| 110 |
-
<
|
| 111 |
Login with Google <i class="bx bxl-google ml-2"></i>
|
| 112 |
-
</
|
| 113 |
-
<
|
| 114 |
Login with GitHub <i class="bx bxl-github ml-2"></i>
|
| 115 |
-
</
|
| 116 |
</div>
|
| 117 |
<p class="mt-4">Don't have an account? <a href="/register" class="text-emerald-300 hover:underline">Register</a></p>
|
| 118 |
<p id="errorMsg" class="text-red-500 mt-4 hidden"></p>
|
|
@@ -227,39 +224,72 @@
|
|
| 227 |
function closeCardDetails(cardId) {
|
| 228 |
document.getElementById(`${cardId}-details`).classList.add('hidden');
|
| 229 |
}
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 259 |
});
|
| 260 |
-
});
|
| 261 |
}
|
| 262 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 263 |
</script>
|
| 264 |
</body>
|
| 265 |
</html>
|
|
|
|
| 9 |
<meta name="robots" content="index, follow">
|
| 10 |
<title>Login - MGZon Chatbot</title>
|
| 11 |
<!-- manifest for Android/Chrome -->
|
| 12 |
+
<link rel="manifest" href="/static/manifest.json">
|
| 13 |
+
<!-- iOS Web App Support -->
|
| 14 |
+
<link rel="apple-touch-icon" sizes="180x180" href="/static/images/mg-180.png">
|
| 15 |
+
<meta name="apple-mobile-web-app-capable" content="yes">
|
| 16 |
+
<meta name="apple-mobile-web-app-title" content="MGZon">
|
| 17 |
+
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
| 18 |
+
<!-- General Theme -->
|
| 19 |
+
<meta name="theme-color" content="#2d3748">
|
|
|
|
|
|
|
|
|
|
| 20 |
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
|
| 21 |
<!-- Open Graph -->
|
| 22 |
<meta property="og:title" content="Login - MGZon Chatbot">
|
|
|
|
| 30 |
<meta name="twitter:description" content="Login to MGZon Chatbot to access AI-powered code generation and e-commerce tools.">
|
| 31 |
<meta name="twitter:image" content="/static/images/mg.svg">
|
| 32 |
<!-- JSON-LD -->
|
| 33 |
+
<script type="application/ld+json">
|
| 34 |
+
{
|
| 35 |
+
"@context": "https://schema.org",
|
| 36 |
+
"@type": "WebPage",
|
| 37 |
+
"name": "Login - MGZon Chatbot",
|
| 38 |
+
"url": "https://mgzon-mgzon-app.hf.space/login",
|
| 39 |
+
"description": "Login to MGZon Chatbot to access AI-powered code generation and e-commerce tools. Sign in with email, Google, or GitHub.",
|
| 40 |
+
"keywords": ["MGZon Chatbot", "login", "AI chatbot", "code generation", "e-commerce", "Mark Al-Asfar", "MGZon", "MGZon AI", "E-commerce chatbot", "Python AI chatbot", "FastAPI integration"],
|
| 41 |
+
"isPartOf": {
|
| 42 |
+
"@type": "WebSite",
|
| 43 |
+
"name": "MGZon Chatbot",
|
| 44 |
+
"url": "https://mgzon-mgzon-app.hf.space/"
|
| 45 |
+
}
|
| 46 |
}
|
| 47 |
+
</script>
|
|
|
|
| 48 |
<!-- Tailwind (v3) -->
|
| 49 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 50 |
<!-- Boxicons -->
|
|
|
|
| 104 |
</button>
|
| 105 |
</form>
|
| 106 |
<div class="flex justify-center gap-4 mt-4 flex-wrap">
|
| 107 |
+
<button id="googleLoginBtn" class="inline-flex items-center bg-gradient-to-r from-white to-gray-200 text-gray-800 px-6 py-3 rounded-full font-semibold hover:scale-105 transition-transform">
|
| 108 |
Login with Google <i class="bx bxl-google ml-2"></i>
|
| 109 |
+
</button>
|
| 110 |
+
<button id="githubLoginBtn" class="inline-flex items-center bg-gradient-to-r from-gray-800 to-black text-white px-6 py-3 rounded-full font-semibold hover:scale-105 transition-transform">
|
| 111 |
Login with GitHub <i class="bx bxl-github ml-2"></i>
|
| 112 |
+
</button>
|
| 113 |
</div>
|
| 114 |
<p class="mt-4">Don't have an account? <a href="/register" class="text-emerald-300 hover:underline">Register</a></p>
|
| 115 |
<p id="errorMsg" class="text-red-500 mt-4 hidden"></p>
|
|
|
|
| 224 |
function closeCardDetails(cardId) {
|
| 225 |
document.getElementById(`${cardId}-details`).classList.add('hidden');
|
| 226 |
}
|
| 227 |
+
// Google Login
|
| 228 |
+
document.getElementById('googleLoginBtn').addEventListener('click', async () => {
|
| 229 |
+
try {
|
| 230 |
+
const response = await fetch('/auth/google/authorize');
|
| 231 |
+
const data = await response.json();
|
| 232 |
+
if (data.authorization_url) {
|
| 233 |
+
window.location.href = data.authorization_url;
|
| 234 |
+
} else {
|
| 235 |
+
console.error('No authorization URL received');
|
| 236 |
+
errorMsg.textContent = 'Error starting Google login. Try again.';
|
| 237 |
+
errorMsg.classList.remove('hidden');
|
| 238 |
+
}
|
| 239 |
+
} catch (error) {
|
| 240 |
+
console.error('Error initiating Google login:', error);
|
| 241 |
+
errorMsg.textContent = 'Error starting Google login. Try again.';
|
| 242 |
+
errorMsg.classList.remove('hidden');
|
| 243 |
+
}
|
| 244 |
+
});
|
| 245 |
+
// GitHub Login
|
| 246 |
+
document.getElementById('githubLoginBtn').addEventListener('click', async () => {
|
| 247 |
+
try {
|
| 248 |
+
const response = await fetch('/auth/github/authorize');
|
| 249 |
+
const data = await response.json();
|
| 250 |
+
if (data.authorization_url) {
|
| 251 |
+
window.location.href = data.authorization_url;
|
| 252 |
+
} else {
|
| 253 |
+
console.error('No authorization URL received');
|
| 254 |
+
errorMsg.textContent = 'Error starting GitHub login. Try again.';
|
| 255 |
+
errorMsg.classList.remove('hidden');
|
| 256 |
+
}
|
| 257 |
+
} catch (error) {
|
| 258 |
+
console.error('Error initiating GitHub login:', error);
|
| 259 |
+
errorMsg.textContent = 'Error starting GitHub login. Try again.';
|
| 260 |
+
errorMsg.classList.remove('hidden');
|
| 261 |
+
}
|
| 262 |
+
});
|
| 263 |
+
// تسجيل Service Worker لتفعيل الـ PWA
|
| 264 |
+
if ('serviceWorker' in navigator) {
|
| 265 |
+
navigator.serviceWorker.register('/static/js/sw.js')
|
| 266 |
+
.then(function(reg) {
|
| 267 |
+
console.log('✅ Service Worker Registered', reg);
|
| 268 |
+
}).catch(function(err) {
|
| 269 |
+
console.error('❌ Service Worker registration failed', err);
|
| 270 |
});
|
|
|
|
| 271 |
}
|
| 272 |
+
// التعامل مع حدث beforeinstallprompt لتثبيت التطبيق
|
| 273 |
+
let deferredPrompt;
|
| 274 |
+
window.addEventListener('beforeinstallprompt', (e) => {
|
| 275 |
+
e.preventDefault();
|
| 276 |
+
deferredPrompt = e;
|
| 277 |
+
const installBtn = document.getElementById('installAppBtn');
|
| 278 |
+
if (installBtn) {
|
| 279 |
+
installBtn.style.display = 'block';
|
| 280 |
+
installBtn.addEventListener('click', () => {
|
| 281 |
+
deferredPrompt.prompt();
|
| 282 |
+
deferredPrompt.userChoice.then(choice => {
|
| 283 |
+
if (choice.outcome === 'accepted') {
|
| 284 |
+
console.log('✅ User accepted the install prompt');
|
| 285 |
+
} else {
|
| 286 |
+
console.log('❌ User dismissed the install prompt');
|
| 287 |
+
}
|
| 288 |
+
deferredPrompt = null;
|
| 289 |
+
});
|
| 290 |
+
});
|
| 291 |
+
}
|
| 292 |
+
});
|
| 293 |
</script>
|
| 294 |
</body>
|
| 295 |
</html>
|