Update static/login.html
Browse files- static/login.html +11 -3
static/login.html
CHANGED
@@ -71,10 +71,18 @@
|
|
71 |
});
|
72 |
|
73 |
if (response.ok) {
|
74 |
-
const
|
75 |
-
localStorage.setItem('accessToken',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
messageEl.style.color = 'green';
|
77 |
-
messageEl.textContent = 'Login successful!
|
78 |
} else {
|
79 |
const errorData = await response.json();
|
80 |
messageEl.textContent = errorData.detail || 'Login failed.';
|
|
|
71 |
});
|
72 |
|
73 |
if (response.ok) {
|
74 |
+
const token = data.access_token; // 'data' is the response from the /token endpoint
|
75 |
+
localStorage.setItem('accessToken', token);
|
76 |
+
|
77 |
+
// Send the token to the parent window (Settings.html)
|
78 |
+
if (window.parent) {
|
79 |
+
// The second argument is the target origin. '*' is less secure but works for local files.
|
80 |
+
window.parent.postMessage({ accessToken: token }, '*');
|
81 |
+
}
|
82 |
+
|
83 |
+
// Update UI to show success message instead of redirecting
|
84 |
messageEl.style.color = 'green';
|
85 |
+
messageEl.textContent = 'Login successful! You can now close this window.';
|
86 |
} else {
|
87 |
const errorData = await response.json();
|
88 |
messageEl.textContent = errorData.detail || 'Login failed.';
|