-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgpt.html
95 lines (91 loc) · 3.19 KB
/
gpt.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Firebase Authentication Example</title>
<script type="module">
// Import the functions you need from the SDKs you need
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.7.1/firebase-app.js";
import { getAnalytics } from "https://www.gstatic.com/firebasejs/10.7.1/firebase-analytics.js";
import { getAuth, signInWithEmailAndPassword, onAuthStateChanged } from "https://www.gstatic.com/firebasejs/10.7.1/firebase-auth.js";
// Your web app's Firebase configuration
const firebaseConfig = {
apiKey: "AIzaSyBH3LvyIKTVeEZ4KYFbxFAWumn2B9GtzTE",
authDomain: "cmepass-391c3.firebaseapp.com",
projectId: "cmepass-391c3",
storageBucket: "cmepass-391c3.appspot.com",
messagingSenderId: "495360510420",
appId: "1:495360510420:web:338107bc68b5f0bb7e2e41",
measurementId: "G-DL15HN05NG"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);
const auth = getAuth(app);
// Sign in function
function signIn() {
var email = document.getElementById('email').value;
var password = document.getElementById('password').value;
signInWithEmailAndPassword(auth, email, password)
.then((userCredential) => {
// Signed in
document.getElementById('status').innerText = 'Logged in successfully. Welcome, ' + userCredential.user.email;
})
.catch((error) => {
var errorCode = error.code;
var errorMessage = error.message;
document.getElementById('status').innerText = 'Error: ' + errorMessage;
});
}
// Auth state changes
onAuthStateChanged(auth, (user) => {
if (user) {
// User is signed in
document.getElementById('status').innerText = 'User is currently signed in';
} else {
// User is signed out
document.getElementById('status').innerText = 'User is signed out';
}
});
</script>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
background-color: #f4f4f4;
margin: 0;
padding: 20px;
}
input {
margin: 10px 0;
padding: 10px;
border: 1px solid #ddd;
border-radius: 4px;
width: 200px;
}
button {
padding: 10px 20px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
button:hover {
background-color: #45a049;
}
#status {
margin-top: 20px;
color: #d9534f;
}
</style>
</head>
<body>
<h1>Firebase Authentication Example</h1>
<input type="email" id="email" placeholder="Email">
<input type="password" id="password" placeholder="Password">
<button onclick="signIn()">Sign In</button>
<div id="status"></div>
</body>
</html>