Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- admin-panel.html +11 -7
- student-login.html +18 -12
- teacher-login.html +9 -17
admin-panel.html
CHANGED
|
@@ -32,11 +32,8 @@
|
|
| 32 |
</div>
|
| 33 |
</div>
|
| 34 |
|
| 35 |
-
<div style="margin:24px 0">
|
| 36 |
-
<
|
| 37 |
-
<img src="https://www.gstatic.com/firebasejs/ui/2.0.0/images/auth/google.svg" alt="Google">
|
| 38 |
-
Sign in with Google
|
| 39 |
-
</button>
|
| 40 |
</div>
|
| 41 |
|
| 42 |
<div id="adminLoadingState" class="auth-loading hidden">
|
|
@@ -438,7 +435,8 @@ async function verifyAdminInDB(googleUser) {
|
|
| 438 |
document.getElementById('adminLoadingState').classList.remove('hidden');
|
| 439 |
document.getElementById('adminGoogleBtn').disabled = true;
|
| 440 |
try {
|
| 441 |
-
|
|
|
|
| 442 |
const users = result.data || [];
|
| 443 |
const user = users.find(u => u.email && u.email.toLowerCase() === googleUser.email.toLowerCase());
|
| 444 |
|
|
@@ -465,7 +463,7 @@ async function verifyAdminInDB(googleUser) {
|
|
| 465 |
showAdminAuthAlert('System error during verification. Please try again.', 'danger');
|
| 466 |
} finally {
|
| 467 |
document.getElementById('adminLoadingState').classList.add('hidden');
|
| 468 |
-
|
| 469 |
}
|
| 470 |
}
|
| 471 |
|
|
@@ -994,6 +992,12 @@ window.addEventListener('load', () => {
|
|
| 994 |
checkAdminAuth();
|
| 995 |
if (APP_CONFIG.googleClientId !== 'YOUR_GOOGLE_CLIENT_ID.apps.googleusercontent.com' && typeof google !== 'undefined') {
|
| 996 |
google.accounts.id.initialize({ client_id: APP_CONFIG.googleClientId, callback: handleGoogleCredential, auto_select: false });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 997 |
}
|
| 998 |
});
|
| 999 |
</script>
|
|
|
|
| 32 |
</div>
|
| 33 |
</div>
|
| 34 |
|
| 35 |
+
<div style="margin:24px 0; display: flex; justify-content: center;">
|
| 36 |
+
<div id="adminGoogleBtnContainer"></div>
|
|
|
|
|
|
|
|
|
|
| 37 |
</div>
|
| 38 |
|
| 39 |
<div id="adminLoadingState" class="auth-loading hidden">
|
|
|
|
| 435 |
document.getElementById('adminLoadingState').classList.remove('hidden');
|
| 436 |
document.getElementById('adminGoogleBtn').disabled = true;
|
| 437 |
try {
|
| 438 |
+
// Exact email lookup
|
| 439 |
+
const result = await API.get('users', { email: googleUser.email });
|
| 440 |
const users = result.data || [];
|
| 441 |
const user = users.find(u => u.email && u.email.toLowerCase() === googleUser.email.toLowerCase());
|
| 442 |
|
|
|
|
| 463 |
showAdminAuthAlert('System error during verification. Please try again.', 'danger');
|
| 464 |
} finally {
|
| 465 |
document.getElementById('adminLoadingState').classList.add('hidden');
|
| 466 |
+
// Official button is managed by Google
|
| 467 |
}
|
| 468 |
}
|
| 469 |
|
|
|
|
| 992 |
checkAdminAuth();
|
| 993 |
if (APP_CONFIG.googleClientId !== 'YOUR_GOOGLE_CLIENT_ID.apps.googleusercontent.com' && typeof google !== 'undefined') {
|
| 994 |
google.accounts.id.initialize({ client_id: APP_CONFIG.googleClientId, callback: handleGoogleCredential, auto_select: false });
|
| 995 |
+
|
| 996 |
+
// Render official Google button
|
| 997 |
+
google.accounts.id.renderButton(
|
| 998 |
+
document.getElementById("adminGoogleBtnContainer"),
|
| 999 |
+
{ theme: "outline", size: "large", width: "100%", text: "signin_with", shape: "rectangular" }
|
| 1000 |
+
);
|
| 1001 |
}
|
| 1002 |
});
|
| 1003 |
</script>
|
student-login.html
CHANGED
|
@@ -72,12 +72,9 @@
|
|
| 72 |
</div>
|
| 73 |
</div>
|
| 74 |
|
| 75 |
-
<!-- Google Sign In Button -->
|
| 76 |
-
<div style="margin: 24px 0;">
|
| 77 |
-
<
|
| 78 |
-
<img src="https://www.gstatic.com/firebasejs/ui/2.0.0/images/auth/google.svg" alt="Google">
|
| 79 |
-
Continue with Google
|
| 80 |
-
</button>
|
| 81 |
</div>
|
| 82 |
|
| 83 |
<!-- Loading State -->
|
|
@@ -175,7 +172,7 @@
|
|
| 175 |
|
| 176 |
function hideLoading() {
|
| 177 |
document.getElementById('loadingState').classList.add('hidden');
|
| 178 |
-
|
| 179 |
}
|
| 180 |
|
| 181 |
function showUnauthorized(email, message) {
|
|
@@ -206,11 +203,8 @@
|
|
| 206 |
try {
|
| 207 |
showLoading('Checking student database...');
|
| 208 |
|
| 209 |
-
// Search for user by email
|
| 210 |
-
const result = await API.get('users', {
|
| 211 |
-
search: googleUser.email,
|
| 212 |
-
limit: 100
|
| 213 |
-
});
|
| 214 |
|
| 215 |
const users = result.data || [];
|
| 216 |
const user = users.find(u =>
|
|
@@ -321,6 +315,18 @@
|
|
| 321 |
auto_select: false,
|
| 322 |
cancel_on_tap_outside: true
|
| 323 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 324 |
}
|
| 325 |
}
|
| 326 |
});
|
|
|
|
| 72 |
</div>
|
| 73 |
</div>
|
| 74 |
|
| 75 |
+
<!-- Google Sign In Button Container -->
|
| 76 |
+
<div style="margin: 24px 0; display: flex; justify-content: center;">
|
| 77 |
+
<div id="googleBtnContainer"></div>
|
|
|
|
|
|
|
|
|
|
| 78 |
</div>
|
| 79 |
|
| 80 |
<!-- Loading State -->
|
|
|
|
| 172 |
|
| 173 |
function hideLoading() {
|
| 174 |
document.getElementById('loadingState').classList.add('hidden');
|
| 175 |
+
// The official button is managed by Google SDK
|
| 176 |
}
|
| 177 |
|
| 178 |
function showUnauthorized(email, message) {
|
|
|
|
| 203 |
try {
|
| 204 |
showLoading('Checking student database...');
|
| 205 |
|
| 206 |
+
// Search for user by exact email
|
| 207 |
+
const result = await API.get('users', { email: googleUser.email });
|
|
|
|
|
|
|
|
|
|
| 208 |
|
| 209 |
const users = result.data || [];
|
| 210 |
const user = users.find(u =>
|
|
|
|
| 315 |
auto_select: false,
|
| 316 |
cancel_on_tap_outside: true
|
| 317 |
});
|
| 318 |
+
|
| 319 |
+
// Render the official Google button
|
| 320 |
+
google.accounts.id.renderButton(
|
| 321 |
+
document.getElementById("googleBtnContainer"),
|
| 322 |
+
{
|
| 323 |
+
theme: "outline",
|
| 324 |
+
size: "large",
|
| 325 |
+
width: "100%",
|
| 326 |
+
text: "continue_with",
|
| 327 |
+
shape: "rectangular"
|
| 328 |
+
}
|
| 329 |
+
);
|
| 330 |
}
|
| 331 |
}
|
| 332 |
});
|
teacher-login.html
CHANGED
|
@@ -64,11 +64,9 @@
|
|
| 64 |
</div>
|
| 65 |
</div>
|
| 66 |
|
| 67 |
-
<
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
Continue with Google
|
| 71 |
-
</button>
|
| 72 |
</div>
|
| 73 |
|
| 74 |
<div id="loadingState" class="auth-loading hidden">
|
|
@@ -142,12 +140,10 @@
|
|
| 142 |
function showLoading(text) {
|
| 143 |
document.getElementById('loadingState').classList.remove('hidden');
|
| 144 |
document.getElementById('loadingText').textContent = text || 'Verifying faculty credentials...';
|
| 145 |
-
document.getElementById('googleSignInBtn').disabled = true;
|
| 146 |
}
|
| 147 |
|
| 148 |
function hideLoading() {
|
| 149 |
document.getElementById('loadingState').classList.add('hidden');
|
| 150 |
-
document.getElementById('googleSignInBtn').disabled = false;
|
| 151 |
}
|
| 152 |
|
| 153 |
function showUnauthorized(email, message) {
|
|
@@ -167,7 +163,7 @@
|
|
| 167 |
async function verifyTeacherInDB(googleUser) {
|
| 168 |
try {
|
| 169 |
showLoading('Checking faculty database...');
|
| 170 |
-
const result = await API.get('users', {
|
| 171 |
const users = result.data || [];
|
| 172 |
const user = users.find(u => u.email && u.email.toLowerCase() === googleUser.email.toLowerCase());
|
| 173 |
|
|
@@ -229,18 +225,14 @@
|
|
| 229 |
}
|
| 230 |
}
|
| 231 |
|
| 232 |
-
function initiateGoogleLogin() {
|
| 233 |
-
if (APP_CONFIG.googleClientId === 'YOUR_GOOGLE_CLIENT_ID.apps.googleusercontent.com') {
|
| 234 |
-
showAlert('<strong>Google OAuth Not Configured</strong><br>An administrator must set up the Google OAuth Client ID before login is available.', 'warning');
|
| 235 |
-
return;
|
| 236 |
-
}
|
| 237 |
-
if (typeof google !== 'undefined' && google.accounts) google.accounts.id.prompt();
|
| 238 |
-
else showAlert('Google auth service unavailable.', 'warning');
|
| 239 |
-
}
|
| 240 |
-
|
| 241 |
window.addEventListener('load', () => {
|
| 242 |
if (APP_CONFIG.googleClientId !== 'YOUR_GOOGLE_CLIENT_ID.apps.googleusercontent.com' && typeof google !== 'undefined') {
|
| 243 |
google.accounts.id.initialize({ client_id: APP_CONFIG.googleClientId, callback: handleGoogleCredential, auto_select: false });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 244 |
}
|
| 245 |
});
|
| 246 |
</script>
|
|
|
|
| 64 |
</div>
|
| 65 |
</div>
|
| 66 |
|
| 67 |
+
<!-- Google Sign In Button Container -->
|
| 68 |
+
<div style="margin:24px 0; display: flex; justify-content: center;">
|
| 69 |
+
<div id="googleBtnContainer"></div>
|
|
|
|
|
|
|
| 70 |
</div>
|
| 71 |
|
| 72 |
<div id="loadingState" class="auth-loading hidden">
|
|
|
|
| 140 |
function showLoading(text) {
|
| 141 |
document.getElementById('loadingState').classList.remove('hidden');
|
| 142 |
document.getElementById('loadingText').textContent = text || 'Verifying faculty credentials...';
|
|
|
|
| 143 |
}
|
| 144 |
|
| 145 |
function hideLoading() {
|
| 146 |
document.getElementById('loadingState').classList.add('hidden');
|
|
|
|
| 147 |
}
|
| 148 |
|
| 149 |
function showUnauthorized(email, message) {
|
|
|
|
| 163 |
async function verifyTeacherInDB(googleUser) {
|
| 164 |
try {
|
| 165 |
showLoading('Checking faculty database...');
|
| 166 |
+
const result = await API.get('users', { email: googleUser.email });
|
| 167 |
const users = result.data || [];
|
| 168 |
const user = users.find(u => u.email && u.email.toLowerCase() === googleUser.email.toLowerCase());
|
| 169 |
|
|
|
|
| 225 |
}
|
| 226 |
}
|
| 227 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 228 |
window.addEventListener('load', () => {
|
| 229 |
if (APP_CONFIG.googleClientId !== 'YOUR_GOOGLE_CLIENT_ID.apps.googleusercontent.com' && typeof google !== 'undefined') {
|
| 230 |
google.accounts.id.initialize({ client_id: APP_CONFIG.googleClientId, callback: handleGoogleCredential, auto_select: false });
|
| 231 |
+
|
| 232 |
+
google.accounts.id.renderButton(
|
| 233 |
+
document.getElementById("googleBtnContainer"),
|
| 234 |
+
{ theme: "outline", size: "large", width: "100%", text: "continue_with", shape: "rectangular" }
|
| 235 |
+
);
|
| 236 |
}
|
| 237 |
});
|
| 238 |
</script>
|