-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
47dab5b
commit 50cf987
Showing
2 changed files
with
132 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Delete Account</title> | ||
<!-- Include Firebase SDK --> | ||
<script src="https://www.gstatic.com/firebasejs/9.6.10/firebase-app.js"></script> | ||
<script src="https://www.gstatic.com/firebasejs/9.6.10/firebase-auth.js"></script> | ||
<script src="https://www.gstatic.com/firebasejs/9.6.10/firebase-firestore.js"></script> | ||
<style> | ||
body { | ||
font-family: Arial, sans-serif; | ||
background-color: #f4f4f4; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100vh; | ||
margin: 0; | ||
} | ||
.container { | ||
background: #fff; | ||
padding: 20px; | ||
border-radius: 8px; | ||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); | ||
width: 300px; | ||
text-align: center; | ||
} | ||
input { | ||
width: 100%; | ||
padding: 10px; | ||
margin: 10px 0; | ||
border: 1px solid #ccc; | ||
border-radius: 4px; | ||
} | ||
button { | ||
background: #ff4d4d; | ||
color: #fff; | ||
border: none; | ||
padding: 10px 20px; | ||
border-radius: 4px; | ||
cursor: pointer; | ||
} | ||
button:hover { | ||
background: #cc0000; | ||
} | ||
.confirmation-dialog { | ||
display: none; | ||
margin-top: 20px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<h2>Delete Account</h2> | ||
<input type="email" id="email" placeholder="Enter your email"> | ||
<input type="password" id="password" placeholder="Enter your password"> | ||
<button onclick="verifyUser()">Verify</button> | ||
|
||
<!-- Confirmation Dialog --> | ||
<div id="confirmation-dialog" class="confirmation-dialog"> | ||
<p>Are you sure you want to delete your account? This action cannot be undone.</p> | ||
<button onclick="deleteAccount()">Yes, Delete My Account</button> | ||
<button onclick="cancelDelete()">Cancel</button> | ||
</div> | ||
|
||
<p id="message" style="color: red; margin-top: 10px;"></p> | ||
</div> | ||
|
||
<script> | ||
// Firebase configuration | ||
const firebaseConfig = { | ||
apiKey: "YOUR_API_KEY", | ||
authDomain: "YOUR_AUTH_DOMAIN", | ||
projectId: "YOUR_PROJECT_ID", | ||
storageBucket: "YOUR_STORAGE_BUCKET", | ||
messagingSenderId: "YOUR_MESSAGING_SENDER_ID", | ||
appId: "YOUR_APP_ID" | ||
}; | ||
|
||
// Initialize Firebase | ||
const app = firebase.initializeApp(firebaseConfig); | ||
const auth = firebase.auth(); | ||
const db = firebase.firestore(); | ||
|
||
// Verify user credentials | ||
function verifyUser() { | ||
const email = document.getElementById('email').value; | ||
const password = document.getElementById('password').value; | ||
|
||
// Sign in with email and password | ||
auth.signInWithEmailAndPassword(email, password) | ||
.then((userCredential) => { | ||
const user = userCredential.user; | ||
document.getElementById('confirmation-dialog').style.display = 'block'; | ||
document.getElementById('message').textContent = ''; | ||
}) | ||
.catch((error) => { | ||
document.getElementById('message').textContent = 'Invalid email or password.'; | ||
}); | ||
} | ||
|
||
// Delete account | ||
function deleteAccount() { | ||
const user = auth.currentUser; | ||
|
||
// Delete user from Firebase Authentication | ||
user.delete() | ||
.then(() => { | ||
// Delete user data from Firestore | ||
db.collection('users').doc(user.uid).delete() | ||
.then(() => { | ||
document.getElementById('message').textContent = 'Account deleted successfully.'; | ||
document.getElementById('confirmation-dialog').style.display = 'none'; | ||
}) | ||
.catch((error) => { | ||
document.getElementById('message').textContent = 'Error deleting user data.'; | ||
}); | ||
}) | ||
.catch((error) => { | ||
document.getElementById('message').textContent = 'Error deleting account.'; | ||
}); | ||
} | ||
|
||
// Cancel delete | ||
function cancelDelete() { | ||
document.getElementById('confirmation-dialog').style.display = 'none'; | ||
} | ||
</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 |
---|---|---|
|
@@ -50,7 +50,7 @@ | |
</a> | ||
</li> | ||
<li> | ||
<a href='privacy.html' > | ||
<a href='account.html' > | ||
Account | ||
</a> | ||
</li> | ||
|