firebase authentication is hard. i think i will stick to static pages

This commit is contained in:
hexahigh 2023-04-11 18:53:48 +02:00
parent 713f11bfff
commit 5df1032240
5 changed files with 22 additions and 16 deletions

View File

@ -37,22 +37,10 @@ const firebaseConfig = {
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
export const auth = getAuth(app);
const provider = new GoogleAuthProvider()
const analytics = getAnalytics(app);
// Check if google sign up button is pressed
document.getElementById("googleSignButton").addEventListener("click", function () {
signInWithRedirect(auth, provider);
});
auth().onAuthStateChanged(function (user) {
if (user) {
// User is signed in.
} else {
// No user is signed in.
}
});
getRedirectResult(auth)

View File

@ -8,6 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="style.css">
<script src="firebaseLoader.js" type="module"></script>
<script src="index.js" type="module" defer></script>
</head>
<body>

16
admin/index.js Normal file
View File

@ -0,0 +1,16 @@
import { auth } from "./firebaseLoader.js";
// Check if google sign up button is pressed
document.getElementById("googleSignButton").addEventListener("click", function () {
signInWithRedirect(auth, provider);
});
auth().onAuthStateChanged(function (user) {
if (user) {
window.location.href="ui/index.html";
} else {
// No user is signed in.
}
});

View File

@ -16,7 +16,7 @@
<h3 id="signOutButton" class="roboto">Sign out</h3>
</div>
<div class="mainWrapper">
<h1 class="roboto">Admin ui</h1>
<h1 class="roboto">Cool ui</h1>
</div>
</body>

View File

@ -1,11 +1,12 @@
.header {
border-bottom: 1px solid #111;
padding: 1.5rem 5vw;
padding: 0.1rem 1vw;
display: block;
}
.mainWrapper {
align-items: center;
text-align: center;
padding-top: 1rem;
}
.roboto {