Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Firebase authentication functionality #23

Merged
merged 4 commits into from
Apr 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion assets/js/host.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { checkLoginStatus } from './main.js';
import { topics, questions } from './utils/questions.js';

checkLoginStatus({ path: '../../auth/' });
const codeView = document.getElementById('code-view');
const title = document.getElementById('title');
const playerCount = document.getElementById('player-count');
Expand Down
14 changes: 14 additions & 0 deletions assets/js/main.js
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
// check login status from login object in session storage
function checkLoginStatus({ path = './' }) {
console.log(path);
const loginObj = sessionStorage.getItem('login');
if (loginObj) {
const loginObject = JSON.parse(loginObj);
if (!loginObject.loggedIn) {
window.location.href = `${path}login.html`;
}
} else {
window.location.href = `${path}login.html`;
}
}

export { checkLoginStatus };
3 changes: 2 additions & 1 deletion assets/js/postquiz.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { checkLoginStatus } from './main.js';
import { topics, questions } from './utils/questions.js';

checkLoginStatus({ path: '../auth/' });
const topicID =
new URLSearchParams(window.location.search).get('topic') || undefined;
const gamePin =
Expand Down
2 changes: 2 additions & 0 deletions assets/js/quiz.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { checkLoginStatus } from './main.js';
import { questions, topics } from './utils/questions.js';
checkLoginStatus({ path: '../auth/' });

const quizOptBtns = document.querySelectorAll('.quiz-opt-btn');
const quizTimer = document.querySelector('.quiz-timer > #timer');
Expand Down
Loading
Loading