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