-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added deleted signUp and login files and fixed bug on login button on…
… hover
- Loading branch information
Showing
5 changed files
with
228 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="stylesheet" href="signUp.css" /> | ||
<title>Sign In</title> | ||
</head> | ||
<body> | ||
<form id="signinForm"> | ||
<div class="container"> | ||
<h1>Sign In</h1> | ||
|
||
<hr> | ||
|
||
|
||
<div class="form"> | ||
<label for="email"><b>Email</b></label> | ||
<input type="email" placeholder="Enter Email" autocomplete="email" id="email" required> | ||
|
||
<label for="psw"><b>Password</b></label> | ||
<input type="password" placeholder="Enter Password" autocomplete="new-password" id="psw" required> | ||
|
||
<div class="buttons"> | ||
<button type="button" class="cancelbtn">Cancel</button> | ||
<button type="submit" class="signinbtn">Sign In</button> | ||
</div> | ||
</div> | ||
</div> | ||
</form> | ||
|
||
<script type="module"> | ||
|
||
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.14.0/firebase-app.js"; | ||
import { getAnalytics } from "https://www.gstatic.com/firebasejs/10.14.0/firebase-analytics.js"; | ||
import { getFirestore, addDoc, collection,getDoc } from "https://www.gstatic.com/firebasejs/10.14.0/firebase-firestore.js"; // Correct import for Firestore | ||
import { getAuth, createUserWithEmailAndPassword ,signInWithEmailAndPassword} from "https://www.gstatic.com/firebasejs/10.14.0/firebase-auth.js"; | ||
|
||
|
||
const firebaseConfig = { | ||
apiKey: "AIzaSyC7ihLRIl47Iu6nk6qh_Ak8i3pSYw3tO4A", | ||
authDomain: "frontend-mentor-cceee.firebaseapp.com", | ||
projectId: "frontend-mentor-cceee", | ||
storageBucket: "frontend-mentor-cceee.appspot.com", | ||
messagingSenderId: "51303965383", | ||
appId: "1:51303965383:web:2f8c20fb952bd844dd94e2", | ||
measurementId: "G-S2BV64K72R", | ||
databaseURL: "https://frontend-mentor-cceee-default-rtdb.firebaseio.com" | ||
}; | ||
|
||
|
||
const app = initializeApp(firebaseConfig); | ||
const analytics = getAnalytics(app); | ||
|
||
|
||
const db = getFirestore(app); | ||
|
||
|
||
const auth = getAuth(); | ||
|
||
|
||
const form = document.getElementById('signinForm'); | ||
form.addEventListener('submit', async (e) => { | ||
e.preventDefault(); | ||
const email = document.getElementById('email').value; | ||
const password = document.getElementById('psw').value; | ||
|
||
|
||
signInWithEmailAndPassword(auth, email, password) | ||
.then((userCredential) => { | ||
|
||
const user = userCredential.user; | ||
const uid=user.uid; | ||
console.log(user); | ||
const displayName = user.displayName ? user.displayName : "User"; | ||
alert("Welcome, " + displayName); | ||
|
||
// ... | ||
}) | ||
.catch((error) => { | ||
const errorCode = error.code; | ||
const errorMessage = error.message; | ||
console.log(errorCode, errorMessage); | ||
}); | ||
}) | ||
|
||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
.container{ | ||
text-align: center; | ||
border:2px solid black; | ||
padding: 10px; | ||
|
||
|
||
|
||
} | ||
.buttons{ | ||
margin-top: 10px; | ||
} | ||
h1{ | ||
font-size: 1.2rem; | ||
} | ||
label{ | ||
font-size: 1rem; | ||
} | ||
.form{ | ||
display: flex; | ||
flex-direction: column; | ||
gap:2px; | ||
align-items: center; | ||
|
||
|
||
} | ||
input{ | ||
padding:2px; | ||
margin-block: 5px; | ||
} | ||
button{ | ||
padding-block:8px; | ||
padding-inline: 15px; | ||
background: #fff; | ||
border-radius: 20px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="stylesheet" href="signUp.css" /> | ||
<title>Sign Up</title> | ||
</head> | ||
<body> | ||
<form id="signupForm" > | ||
<div class="container"> | ||
<h1>Sign Up</h1> | ||
|
||
<hr> | ||
|
||
<div class="form"> | ||
<label for="name"><b>Name</b></label> | ||
<input type="text" placeholder="Enter Name" autocomplete="name" id="name" required> | ||
|
||
<label for="email"><b>Email</b></label> | ||
<input type="email" placeholder="Enter Email" autocomplete="email" id="email" required> | ||
|
||
<label for="psw"><b>Password</b></label> | ||
<input type="password" placeholder="Enter Password" autocomplete="new-password" id="psw" required> | ||
|
||
<label for="psw-repeat"><b>Repeat Password</b></label> | ||
<input type="password" placeholder="Repeat Password" id="psw-repeat" autocomplete="new-password" required> | ||
|
||
<div class="buttons"> | ||
<button type="button" class="cancelbtn">Cancel</button> | ||
<button type="submit" class="signupbtn">Sign Up</button> | ||
</div> | ||
</div> | ||
</div> | ||
</form> | ||
|
||
<script type="module"> | ||
|
||
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.14.0/firebase-app.js"; | ||
import { getAnalytics } from "https://www.gstatic.com/firebasejs/10.14.0/firebase-analytics.js"; | ||
import { getFirestore, addDoc, collection } from "https://www.gstatic.com/firebasejs/10.14.0/firebase-firestore.js"; // Correct import for Firestore | ||
import { getAuth, createUserWithEmailAndPassword ,updateProfile} from "https://www.gstatic.com/firebasejs/10.14.0/firebase-auth.js"; | ||
|
||
const firebaseConfig = { | ||
apiKey: "AIzaSyC7ihLRIl47Iu6nk6qh_Ak8i3pSYw3tO4A", | ||
authDomain: "frontend-mentor-cceee.firebaseapp.com", | ||
projectId: "frontend-mentor-cceee", | ||
storageBucket: "frontend-mentor-cceee.appspot.com", | ||
messagingSenderId: "51303965383", | ||
appId: "1:51303965383:web:2f8c20fb952bd844dd94e2", | ||
measurementId: "G-S2BV64K72R", | ||
databaseURL: "https://frontend-mentor-cceee-default-rtdb.firebaseio.com" | ||
}; | ||
|
||
|
||
|
||
const app = initializeApp(firebaseConfig); | ||
const analytics = getAnalytics(app); | ||
|
||
|
||
const db = getFirestore(app); | ||
|
||
|
||
const auth = getAuth(); | ||
|
||
|
||
const form = document.getElementById('signupForm'); | ||
form.addEventListener('submit', async (e) => { | ||
e.preventDefault(); | ||
|
||
|
||
const email = document.getElementById('email').value; | ||
const password = document.getElementById('psw').value; | ||
const name = document.getElementById('name').value; | ||
|
||
try { | ||
|
||
const userCredential = await createUserWithEmailAndPassword(auth, email, password); | ||
|
||
const user = userCredential.user; | ||
await updateProfile(user, { displayName: name }); | ||
|
||
await addDoc(collection(db, "users"), { | ||
uid: user.uid, | ||
name: name, | ||
email: email, | ||
}); | ||
|
||
alert('Signed up successfully and data stored in Firestore!'); | ||
|
||
} catch (error) { | ||
const errorMessage = error.message; | ||
alert('Error: ' + errorMessage); | ||
} | ||
}); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters