Skip to content

Commit b45a357

Browse files
authored
Merge pull request #1116 from codecrafted1/fix/issue-1115
fix(auth): restore email-password login flow in login.html
2 parents 1ecf266 + 17acce2 commit b45a357

3 files changed

Lines changed: 41 additions & 2 deletions

File tree

auth.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,19 @@ async function sendMagicLink(email) {
137137
return true; // success
138138
}
139139

140+
// Login using email and password
141+
async function login(email, password) {
142+
var result = await sb.auth.signInWithPassword({
143+
email: email,
144+
password: password
145+
});
146+
147+
if (result.error) {
148+
throw result.error;
149+
}
150+
151+
return result.data;
152+
}
140153

141154
// ============================================================
142155
// EXPOSE FUNCTIONS TO OTHER SCRIPTS
@@ -164,7 +177,6 @@ window.XAYTHEON_AUTH = {
164177
login: login
165178
};
166179

167-
168180
// ============================================================
169181
// INITIALIZE WHEN THE PAGE IS READY
170182
// ============================================================

login.html

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,6 @@ <h4>Email Address (user:email)</h4>
530530
</div>
531531
</div>
532532
</div>
533-
534533
<!-- Inline JS -->
535534
<script>
536535
document.addEventListener("DOMContentLoaded", function () {
@@ -569,6 +568,7 @@ <h4>Email Address (user:email)</h4>
569568
</script>
570569

571570

571+
<script src="https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2"></script>
572572

573573
<script src="auth.js?v=1.0.0"></script>
574574
<script>
@@ -632,6 +632,17 @@ <h4>Email Address (user:email)</h4>
632632
statusEl.className = "success-msg";
633633
statusEl.textContent = message;
634634
}
635+
function getAuthErrorMessage(error) {
636+
if (!error) {
637+
return "Authentication failed.";
638+
}
639+
640+
if (error.code === "INVALID_CREDENTIALS") {
641+
return "Invalid email or password.";
642+
}
643+
644+
return error.message || "Authentication failed.";
645+
}
635646

636647
function setLoading(isLoading) {
637648
submitBtn.disabled = isLoading;

script.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
function safeHtml(str) {
2+
return String(str)
3+
.replaceAll("&", "&amp;")
4+
.replaceAll("<", "&lt;")
5+
.replaceAll(">", "&gt;")
6+
.replaceAll('"', "&quot;")
7+
.replaceAll("'", "&#039;");
8+
}
9+
10+
function safeAttr(url) {
11+
try {
12+
return encodeURI(url);
13+
} catch {
14+
return "#";
15+
}
16+
}
117
// ============================================================
218
// script.js - 3D Background + GitHub Dashboard
319
// ============================================================

0 commit comments

Comments
 (0)