Spaces:
Sleeping
Sleeping
Commit Β·
2a9875e
1
Parent(s): ca9ee10
email authentication added
Browse filesFiles changed (4)
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182<!-- Supabase email template: "Confirm signup" (OTP version β the app asks for this code) Paste into: Supabase Dashboard β Authentication β Email Templates β Confirm signup --><table width="100%" cellpadding="0" cellspacing="0" border="0" bgcolor="#0f1117" style="background-color:#0f1117; padding:40px 16px;"> <tr> <td align="center">
<table width="600" cellpadding="0" cellspacing="0" border="0" style="max-width:600px; width:100%;">
<!-- Brand --> <tr> <td align="center" style="padding-bottom:26px;"> <span style="font-family:'Segoe UI', Arial, sans-serif; font-size:26px; font-weight:700; color:#e8eaf0; letter-spacing:1px;"> <span style="color:#76b900;">◆</span> Docent AI </span><br> <span style="font-family:'Segoe UI', Arial, sans-serif; font-size:12px; letter-spacing:3px; color:#8b90a8; text-transform:uppercase;"> University Policy Assistant </span> </td> </tr>
<!-- Card --> <tr> <td bgcolor="#1a1d27" style="background-color:#1a1d27; border:1px solid #2e3350; border-radius:16px; padding:40px 36px;"> <table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr> <td align="center" style="font-family:'Segoe UI', Arial, sans-serif; font-size:22px; font-weight:700; color:#ffffff; padding-bottom:14px;"> Your verification code </td> </tr>
<tr> <td align="center" style="font-family:'Segoe UI', Arial, sans-serif; font-size:15px; line-height:24px; color:#b7bccf; padding-bottom:28px;"> Welcome to Docent AI! Enter this code on the sign-up screen to activate your account. </td> </tr>
<!-- The code --> <tr> <td align="center" style="padding-bottom:28px;"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td bgcolor="#0f1117" style="background-color:#0f1117; border:1px solid #76b900; border-radius:14px; padding:18px 38px;"> <span style="font-family:'Courier New', Courier, monospace; font-size:34px; font-weight:700; letter-spacing:12px; color:#a8e63d;">{{ .Token }}</span> </td> </tr> </table> </td> </tr>
<tr> <td align="center" style="font-family:'Segoe UI', Arial, sans-serif; font-size:13px; line-height:21px; color:#8b90a8; padding-bottom:24px;"> This code expires in <strong style="color:#b7bccf;">1 hour</strong> and can only be used once. </td> </tr>
<!-- Divider --> <tr> <td style="border-top:1px solid #2e3350; padding-top:20px; font-family:'Segoe UI', Arial, sans-serif; font-size:12px; line-height:19px; color:#8b90a8;"> Didn't create a Docent AI account? You can safely ignore this email — nothing happens without the code. </td> </tr>
</table> </td> </tr>
<!-- Footer --> <tr> <td align="center" style="padding-top:24px; font-family:'Segoe UI', Arial, sans-serif; font-size:11px; line-height:18px; color:#5d637d;"> Docent AI — ask, and the documents answer.<br> This is an automated message; please don't reply to this email. </td> </tr>
</table>
</td> </tr></table>30 unmodified lines3132333435363731 unmodified lines69707172737475767778143 unmodified lines22222322422522622730 unmodified linesif (t) document.documentElement.dataset.theme = t;})();</script><link rel="stylesheet" href="/static/style.css?v=16" /><script src="https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2"></script><script src="https://cdn.jsdelivr.net/npm/pdfjs-dist@3.11.174/build/pdf.min.js"></script><script src="https://cdn.jsdelivr.net/npm/marked@12/marked.min.js"></script>31 unmodified lines<button type="button" class="eye-btn" id="togglePw" title="Show password" tabindex="-1"></button></div><button type="submit" class="auth-submit" id="authSubmit"><span id="authSubmitText">Log in</span><span id="authSpinner" class="spinner hidden"></span></button><button type="button" class="auth-link" id="forgotBtn">Forgot password?</button><button type="button" class="auth-link hidden" id="backToLogin">← Back to log in</button><div id="authMessage" class="auth-message hidden"></div>143 unmodified lines</div></div><script src="/static/script.js?v=21"></script></body></html>30 unmodified lines3132333435363731 unmodified lines697071727374757677787980818283848586878889909192143 unmodified lines23623723823924024130 unmodified linesif (t) document.documentElement.dataset.theme = t;})();</script><link rel="stylesheet" href="/static/style.css?v=18" /><script src="https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2"></script><script src="https://cdn.jsdelivr.net/npm/pdfjs-dist@3.11.174/build/pdf.min.js"></script><script src="https://cdn.jsdelivr.net/npm/marked@12/marked.min.js"></script>31 unmodified lines<button type="button" class="eye-btn" id="togglePw" title="Show password" tabindex="-1"></button></div><button type="submit" class="auth-submit" id="authSubmit"><span id="authSubmitText">Log in</span><span id="authSpinner" class="spinner hidden"></span></button><div class="auth-divider" id="authDivider"><span>or</span></div><button type="button" class="google-btn" id="googleBtn"><svg viewBox="0 0 48 48" aria-hidden="true"><path fill="#FFC107" d="M43.6 20.1H42V20H24v8h11.3C33.7 32.7 29.2 36 24 36c-6.6 0-12-5.4-12-12s5.4-12 12-12c3.1 0 5.9 1.2 8 3l5.7-5.7C34 6.1 29.3 4 24 4 13 4 4 13 4 24s9 20 20 20 20-9 20-20c0-1.3-.1-2.7-.4-3.9z"/><path fill="#FF3D00" d="M6.3 14.7l6.6 4.8C14.7 15.1 19 12 24 12c3.1 0 5.9 1.2 8 3l5.7-5.7C34 6.1 29.3 4 24 4 16.3 4 9.7 8.3 6.3 14.7z"/><path fill="#4CAF50" d="M24 44c5.2 0 9.9-2 13.4-5.2l-6.2-5.2C29.2 35.1 26.7 36 24 36c-5.2 0-9.6-3.3-11.3-8l-6.5 5C9.5 39.6 16.2 44 24 44z"/><path fill="#1976D2" d="M43.6 20.1H42V20H24v8h11.3c-.8 2.2-2.2 4.1-4.1 5.5l6.2 5.2C41.4 34.9 44 30 44 24c0-1.3-.1-2.7-.4-3.9z"/></svg><span id="googleBtnText">Continue with Google</span></button><button type="button" class="auth-link" id="forgotBtn">Forgot password?</button><button type="button" class="auth-link hidden" id="backToLogin">← Back to log in</button><div id="authMessage" class="auth-message hidden"></div>143 unmodified lines</div></div><script src="/static/script.js?v=24"></script></body></html>
21 unmodified lines2223242526271097 unmodified lines11251126112711281129113020 unmodified lines11511152115311541155115625 unmodified lines11821183118411851186118711881189119011911192119376 unmodified lines12701271127212731274127510 unmodified lines128612871288128912901291129221 unmodified linesconst authMessage = document.getElementById('authMessage');const forgotBtn = document.getElementById('forgotBtn');const backToLogin = document.getElementById('backToLogin');const bootLoader = document.getElementById('bootLoader');const accountEmail = document.getElementById('accountEmail');1097 unmodified linesforgotBtn.classList.toggle('hidden', mode !== 'login');backToLogin.classList.toggle('hidden', mode !== 'forgot');authPasswordLabel.textContent = mode === 'recovery' ? 'New password' : 'Password';tabLogin.classList.toggle('active', mode === 'login');tabSignup.classList.toggle('active', mode === 'signup');20 unmodified linestabLogin.addEventListener('click', () => setAuthMode('login'));tabSignup.addEventListener('click', () => setAuthMode('signup'));authForm.addEventListener('submit', async (e) => {e.preventDefault();if (!sb) {25 unmodified linesif (data.session) {await enterApp();} else {showAuthMessage('Account created. If email confirmation is on, check your inbox, then log in.', 'success');setAuthMode('login');}} else {const { error } = await sb.auth.signInWithPassword({ email, password });if (error) { showAuthMessage(error.message); return; }await enterApp();}} catch (err) {76 unmodified lines// we must show the "set new password" form instead of the app.const isRecoveryLink = window.location.hash.includes('type=recovery');sb = window.supabase.createClient(cfg.supabaseUrl, cfg.supabaseAnonKey);sb.auth.onAuthStateChange((event) => {10 unmodified linessetAuthMode('recovery');showAuthMessage('Enter a new password for your account.', 'success');} else if (data.session) {await enterApp();} else {showAuthScreen();}21 unmodified lines2223242526272829301097 unmodified lines1128112911301131113211331134113511361137113820 unmodified lines1159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119025 unmodified lines1216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123876 unmodified lines1315131613171318131913201321132213231324132510 unmodified lines13361337133813391340134113421343134413451346134713481349135021 unmodified linesconst authMessage = document.getElementById('authMessage');const forgotBtn = document.getElementById('forgotBtn');const backToLogin = document.getElementById('backToLogin');const authDivider = document.getElementById('authDivider');const googleBtn = document.getElementById('googleBtn');const googleBtnText = document.getElementById('googleBtnText');const bootLoader = document.getElementById('bootLoader');const accountEmail = document.getElementById('accountEmail');1097 unmodified linesforgotBtn.classList.toggle('hidden', mode !== 'login');backToLogin.classList.toggle('hidden', mode !== 'forgot');// Google sign-in applies to login/signup only, not reset flowsconst showGoogle = mode === 'login' || mode === 'signup';authDivider.classList.toggle('hidden', !showGoogle);googleBtn.classList.toggle('hidden', !showGoogle);authPasswordLabel.textContent = mode === 'recovery' ? 'New password' : 'Password';tabLogin.classList.toggle('active', mode === 'login');tabSignup.classList.toggle('active', mode === 'signup');20 unmodified linestabLogin.addEventListener('click', () => setAuthMode('login'));tabSignup.addEventListener('click', () => setAuthMode('signup'));/* ββ Sign in with Google (Supabase OAuth) ββOne button covers both cases: existing users log in, new Googleaccounts are created automatically. The page redirects to Google,then back here where boot() picks up the fresh session. */googleBtn.addEventListener('click', async () => {if (!sb) {showAuthMessage('Auth is not ready yet. Reload the page and try again.');return;}googleBtn.disabled = true;googleBtnText.textContent = 'Redirecting to Googleβ¦';hideAuthMessage();try {const { error } = await sb.auth.signInWithOAuth({provider: 'google',options: { redirectTo: window.location.origin },});if (error) throw error;// The browser is now navigating away β nothing more to do here.} catch (err) {showAuthMessage(err.message || 'Google sign-in failed. Please try again.');googleBtn.disabled = false;googleBtnText.textContent = 'Continue with Google';}});authForm.addEventListener('submit', async (e) => {e.preventDefault();if (!sb) {25 unmodified linesif (data.session) {await enterApp();} else {// Email confirmation required β point the user at their inboxsetAuthMode('login');authEmail.value = email;showAuthMessage(`A verification email has been sent to ${email}. Confirm it from your inbox, it directly logs in or you can log in here.`, 'success');}} else {const { error } = await sb.auth.signInWithPassword({ email, password });if (error) {// Unverified account β send a fresh verification email automaticallyif (/confirm/i.test(error.message)) {await sb.auth.resend({ type: 'signup', email }).catch(() => {});showAuthMessage(`Your email isn't verified yet. We've sent a new verification email to ${email} β confirm it, then log in.`, 'success');return;}showAuthMessage(error.message);return;}await enterApp();}} catch (err) {76 unmodified lines// we must show the "set new password" form instead of the app.const isRecoveryLink = window.location.hash.includes('type=recovery');// A failed/denied Google sign-in comes back with the reason in the hashconst oauthError = new URLSearchParams(window.location.hash.slice(1)).get('error_description');sb = window.supabase.createClient(cfg.supabaseUrl, cfg.supabaseAnonKey);sb.auth.onAuthStateChange((event) => {10 unmodified linessetAuthMode('recovery');showAuthMessage('Enter a new password for your account.', 'success');} else if (data.session) {// After an OAuth redirect the tokens sit in the URL hash β remove themif (window.location.hash.includes('access_token')) {history.replaceState(null, '', window.location.pathname);}await enterApp();} else if (oauthError) {history.replaceState(null, '', window.location.pathname);showAuthScreen();showAuthMessage(`Google sign-in failed: ${oauthError}`);} else {showAuthScreen();}
870 unmodified lines871872873874875876870 unmodified lines.stat-doc { flex: 1; min-width: 0; }.stat-count { color: var(--accent); font-weight: 700; flex-shrink: 0; }/* ββ Auth extras ββ */.auth-link {background: none;870 unmodified lines871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921870 unmodified lines.stat-doc { flex: 1; min-width: 0; }.stat-count { color: var(--accent); font-weight: 700; flex-shrink: 0; }/* ββ Sign in with Google ββ */.auth-divider {display: flex;align-items: center;gap: 12px;margin: 16px 0 4px;color: var(--text-muted);font-size: .74rem;text-transform: uppercase;letter-spacing: .08em;}.auth-divider::before,.auth-divider::after {content: "";flex: 1;height: 1px;background: var(--border);}.google-btn {display: flex;align-items: center;justify-content: center;gap: 10px;margin-top: 10px;padding: 11px;background: var(--surface2);color: var(--text);border: 1px solid var(--border);border-radius: var(--radius);font-family: var(--font);font-size: .9rem;font-weight: 600;cursor: pointer;transition: border-color .2s, background .2s, transform .16s var(--ease), box-shadow .16s var(--ease);}.google-btn:hover:not(:disabled) {border-color: var(--accent);transform: translateY(-1px);box-shadow: 0 4px 14px rgba(0, 0, 0, .18);}.google-btn:active:not(:disabled) { transform: translateY(0); }.google-btn:disabled { opacity: .6; cursor: wait; }.google-btn svg { width: 18px; height: 18px; flex-shrink: 0; }/* ββ Auth extras ββ */.auth-link {background: none;
email_templates/confirm-signup-otp.htmlAdded+82
frontend/index.html+16-2
frontend/script.js+60-2
frontend/style.css+45