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

Implement Access Token Check and Redirect #321

Merged
merged 8 commits into from
Oct 28, 2024
Merged
1 change: 0 additions & 1 deletion login-system/logout.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const logout = async (req, res) => {
localStorage.removeItem("accessToken");
res.sendStatus(200);
};

Expand Down
4 changes: 4 additions & 0 deletions public/allotment.html
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ <h4 style="font-size: 28px;text-align: center;margin: 0px;">Allot Faculty</h4>
</div>
</div>
<script>
const token = localStorage.getItem('accessToken');
if (!token) {
window.location.href = '/';
}
window.embeddedChatbotConfig = {
chatbotId: "iSwsMwg5TfWCzADbpz05-",
domain: "www.chatbase.co"
Expand Down
4 changes: 4 additions & 0 deletions public/choose-file.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@

<div style="position: absolute; bottom: 30px; left: 30px;" class="gtranslate_wrapper"></div>
<script>
const token = localStorage.getItem('accessToken');
if (!token) {
ygowthamr marked this conversation as resolved.
Show resolved Hide resolved
window.location.href = '/';
}
window.gtranslateSettings = {
default_language: "en",
detect_browser_language: true,
Expand Down
4 changes: 4 additions & 0 deletions public/choose-signup-file.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@
<body>
<div style="position: absolute; bottom: 30px; left: 30px;" class="gtranslate_wrapper"></div>
<script>
const token = localStorage.getItem('accessToken');
if (!token) {
ygowthamr marked this conversation as resolved.
Show resolved Hide resolved
window.location.href = '/';
}
window.gtranslateSettings = {
default_language: "en",
detect_browser_language: true,
Expand Down
2 changes: 1 addition & 1 deletion public/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ <h3 style="margin-left:3vw;font-size: 22px;">Edit Profile</h3>
});

if (response.ok) {
localStorage.removeItem('token'); // Remove the token from storage
localStorage.removeItem('accessToken'); // Remove the token from storage
ygowthamr marked this conversation as resolved.
Show resolved Hide resolved
window.location.href = '/';
} else {
console.error("Logout failed:", response.statusText);
Expand Down
4 changes: 4 additions & 0 deletions public/fac_login.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

<body> <div style="position: absolute; bottom: 30px; left: 30px;" class="gtranslate_wrapper"></div>
<script>
const token = localStorage.getItem('accessToken');
if (token) {
window.location.href = '/';
}
window.gtranslateSettings = {
default_language: "en",
detect_browser_language: true,
Expand Down
4 changes: 4 additions & 0 deletions public/faculty.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ <h4>Quality and Guidelines</h4>
</div>
</div>
<script>
const token = localStorage.getItem('accessToken');
if (!token) {
window.location.href = '/';
}
var icon =document.getElementById("icon");
icon.onclick = function(){
document.body.classList.toggle("dark-theme");
Expand Down
4 changes: 4 additions & 0 deletions public/form_filling.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
<body>
<div style="position: absolute; bottom: 30px; left: 30px;" class="gtranslate_wrapper"></div>
<script>
const token = localStorage.getItem('accessToken');
if (!token) {
window.location.href = '/';
}
window.gtranslateSettings = {
default_language: "en",
detect_browser_language: true,
Expand Down
4 changes: 4 additions & 0 deletions public/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
<body>

<script>
const token = localStorage.getItem('accessToken');
if (token) {
window.location.href = '/';
}
window.gtranslateSettings = {
default_language: "en",
detect_browser_language: true,
Expand Down
4 changes: 4 additions & 0 deletions public/main_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@

<div style="position: absolute; bottom:30px; left: 30px;" class="gtranslate_wrapper"></div>
<script>
const token = localStorage.getItem('accessToken');
if (!token) {
window.location.href = '/';
}
window.gtranslateSettings = {
default_language: "en",
detect_browser_language: true,
Expand Down
4 changes: 4 additions & 0 deletions public/signup.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@

<div style="position: absolute; bottom: 30px; left: 30px;" class="gtranslate_wrapper"></div>
<script>
const token = localStorage.getItem('accessToken');
if (token) {
window.location.href = '/';
}
window.gtranslateSettings = {
default_language: "en",
detect_browser_language: true,
Expand Down
6 changes: 5 additions & 1 deletion public/stk_dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ <h2 class="mb-0">

<div style="position: absolute; top: 30px; left: 30px;" class="gtranslate_wrapper"></div>
<script>
const token = localStorage.getItem('accessToken');
if (!token) {
window.location.href = '/';
}
window.gtranslateSettings = {
default_language: "en",
detect_browser_language: true,
Expand Down Expand Up @@ -244,7 +248,7 @@ <h2 class="mb-0">
});

if (response.ok) {
localStorage.removeItem('token'); // Remove the token from storage
localStorage.removeItem('accessToken'); // Remove the token from storage
window.location.href = '/';
} else {
console.error("Logout failed:", response.statusText);
Expand Down
4 changes: 4 additions & 0 deletions public/stk_login.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ <h4 style="text-align: center; margin: 0px 0px 10px 0px;font-size: 22px;">(for S

<!-- Updated register function starts here -->
<script>
const token = localStorage.getItem('accessToken');
if (token) {
window.location.href = '/';
}
var icon =document.getElementById("icon");
icon.onclick = function(){
document.body.classList.toggle("dark-theme");
Expand Down
4 changes: 4 additions & 0 deletions public/stk_mainpage.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
<body>
<div style="position: absolute; bottom: 30px; left: 30px;" class="gtranslate_wrapper"></div>
<script>
const token = localStorage.getItem('accessToken');
if (!token) {
window.location.href = '/';
}
window.gtranslateSettings = {
default_language: "en",
detect_browser_language: true,
Expand Down
4 changes: 4 additions & 0 deletions public/stk_signup.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
<body>
<div style="position: absolute; bottom: 30px; left: 30px;" class="gtranslate_wrapper"></div>
<script>
const token = localStorage.getItem('accessToken');
if (token) {
window.location.href = '/';
}
window.gtranslateSettings = {
default_language: "en",
detect_browser_language: true,
Expand Down
4 changes: 4 additions & 0 deletions public/upload_file.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ <h2>Uploaded Research Files</h2>
</div>

<script>
const token = localStorage.getItem('accessToken');
if (!token) {
window.location.href = '/';
}
async function uploadFile() {
const form = document.getElementById('uploadForm');
const status = document.getElementById('status');
Expand Down