vigox / auth.html
Goutam7555's picture
Upload 5 files
78acd7d verified
Raw History Blame Contribute Delete
4.68 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>VIGOX AI Login</title>
<style>
body {
background-color: #000;
color: #fff;
font-family: Arial, sans-serif;
text-align: center;
padding: 50px 20px;
}
h1 {
color: #fff;
font-size: 32px;
margin-bottom: 10px;
}
p {
font-size: 14px;
color: #ccc;
margin-bottom: 30px;
}
input, button {
padding: 12px;
margin: 10px;
font-size: 16px;
border-radius: 10px;
border: none;
width: 100%;
max-width: 280px;
box-sizing: border-box;
}
input {
background-color: #111;
color: #fff;
}
button {
background-color: #00aaff;
color: #fff;
font-weight: bold;
cursor: pointer;
width: 100px;
}
#googleBtn {
background-color: #db4437;
}
#status {
margin-top: 20px;
font-weight: bold;
color: white;
}
</style>
</head>
<body>
<h1>VIGOX <span style="font-weight: 300;">AI</span></h1>
<p>Login or Register to continue</p>
<input type="email" id="email" placeholder="Email" /><br>
<input type="password" id="password" placeholder="Password" /><br>
<button onclick="loginUser()">Login</button>
<button onclick="registerUser()">Register</button><br>
<button id="googleBtn" onclick="googleLogin()">Login with Google</button>
<p id="status"></p>
<!-- Firebase Auth Script -->
<script type="module">
import { initializeApp } from "https://www.gstatic.com/firebasejs/11.9.1/firebase-app.js";
import { getAuth, signInWithEmailAndPassword, createUserWithEmailAndPassword, signInWithPopup, GoogleAuthProvider } from "https://www.gstatic.com/firebasejs/11.9.1/firebase-auth.js";
import { getFirestore, doc, setDoc } from "https://www.gstatic.com/firebasejs/11.9.1/firebase-firestore.js";
const firebaseConfig = {
apiKey: "AIzaSyBdsncjKjed6wpzcbZBWSezYhxVfhqXBRY",
authDomain: "vigox-5cf79.firebaseapp.com",
projectId: "vigox-5cf79",
storageBucket: "vigox-5cf79.appspot.com",
messagingSenderId: "337993976285",
appId: "1:337993976285:web:3a8aaa3f3d4fda8309ce34",
measurementId: "G-LGNXKTWJE2"
};
const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
const db = getFirestore(app);
const provider = new GoogleAuthProvider();
window.loginUser = async function () {
const email = document.getElementById("email").value.trim();
const password = document.getElementById("password").value.trim();
try {
await signInWithEmailAndPassword(auth, email, password);
document.getElementById("status").innerText = "✅ Login successful! Redirecting...";
setTimeout(() => window.location.replace("index.html"), 1500);
} catch (error) {
document.getElementById("status").innerText = "❌ Login failed: " + error.message;
console.error("Login error:", error);
}
};
window.registerUser = async function () {
const email = document.getElementById("email").value.trim();
const password = document.getElementById("password").value.trim();
try {
const userCredential = await createUserWithEmailAndPassword(auth, email, password);
const user = userCredential.user;
await setDoc(doc(db, "users", user.uid), {
uid: user.uid,
email: user.email,
createdAt: new Date().toISOString()
});
document.getElementById("status").innerText = "✅ Registration successful! You can now log in.";
} catch (error) {
document.getElementById("status").innerText = "❌ Registration failed: " + error.message;
console.error("Registration error:", error);
}
};
window.googleLogin = async function () {
try {
const result = await signInWithPopup(auth, provider);
const user = result.user;
await setDoc(doc(db, "users", user.uid), {
uid: user.uid,
email: user.email,
name: user.displayName,
photoURL: user.photoURL,
createdAt: new Date().toISOString()
});
document.getElementById("status").innerText = "✅ Google login successful! Redirecting...";
setTimeout(() => window.location.replace("index.html"), 1500);
} catch (error) {
document.getElementById("status").innerText = "❌ Google login failed: " + error.message;
console.error("Google login error:", error);
}
};
</script>
</body>
</html>