Skip to content

Commit

Permalink
Merge pull request Harshdev098#321 from ygowthamr/RNSessionsPages
Browse files Browse the repository at this point in the history
Implement Access Token Check and Redirect
  • Loading branch information
Harshdev098 authored Oct 28, 2024
2 parents c05cf92 + 0aeb998 commit f9a7613
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 6 deletions.
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
8 changes: 6 additions & 2 deletions public/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ <h3 style="margin-left:3vw;font-size: 22px;">Edit Profile</h3>
}
</style>
<script>
const token = localStorage.getItem('accessToken');
if (!token) {
window.location.href = '/';
}
function openEditModal() {
document.getElementById('profileContainer').style.display = 'none';
document.getElementById('editProfileModal').style.display = 'block';
Expand Down Expand Up @@ -243,7 +247,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
window.location.href = '/';
} else {
console.error("Logout failed:", response.statusText);
Expand Down Expand Up @@ -324,4 +328,4 @@ <h3 style="margin-left:3vw;font-size: 22px;">Edit Profile</h3>
</script>
</body>

</html>
</html>
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/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
2 changes: 1 addition & 1 deletion public/signup.html
Original file line number Diff line number Diff line change
Expand Up @@ -265,4 +265,4 @@ <h4 style="text-align: center; margin: 6px 0px 10px 0px;font-size: 22px;">(for R

</body>

</html>
</html>
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_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
2 changes: 1 addition & 1 deletion public/stk_signup.html
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,4 @@ <h2 style="text-align: center;">Sign Up</h2>
</script>
</body>

</html>
</html>
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

0 comments on commit f9a7613

Please sign in to comment.