forked from pwndoc/pwndoc
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
69 changed files
with
17,455 additions
and
37,026 deletions.
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
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM node:lts-alpine AS build | ||
FROM node:18-alpine AS build | ||
|
||
RUN mkdir -p /app | ||
WORKDIR /app | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import Affix from 'vue-affix'; | ||
|
||
export default ({ Vue }) => { | ||
Vue.use(Affix); | ||
} | ||
import { createApp } from 'vue'; | ||
import { Affix } from 'vue-affix'; | ||
import App from '../App.vue'; | ||
const app = createApp(App); | ||
app.use(Affix); |
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 |
---|---|---|
@@ -1,77 +1,83 @@ | ||
import User from '@/services/user'; | ||
import {isSSO} from '../config/config.json' | ||
import {refreshToken, isAuth} from '@/services/user' | ||
import config from '../config/config.json' | ||
import { ref } from 'vue' | ||
import router from '../router/index' | ||
|
||
export default async ({ urlPath, router, redirect }) => { | ||
// Launch refresh token countdown 840000=14min if not on login page | ||
setInterval(() => { | ||
User.refreshToken() | ||
.then() | ||
.catch(err => { | ||
//SSO redirection | ||
if (isSSO) { | ||
if (!router.currentRoute.path.startsWith('/api/sso')) | ||
if (err === 'Expired refreshToken') | ||
redirect('/api/sso?tokenError=2') | ||
else | ||
redirect('/api/sso') | ||
} | ||
else { | ||
if (!router.currentRoute.path.startsWith('/login')) | ||
if (err === 'Expired refreshToken') | ||
redirect('/login?tokenError=2') | ||
else | ||
redirect('/login') | ||
} | ||
}) | ||
}, 840000) | ||
const isSSO = config.isSSO | ||
export function setupNavigation() { | ||
|
||
// Create a ref to track authentication status | ||
const tokenRefreshInterval = ref(null) | ||
|
||
// Call refreshToken when loading app and redirect to login if error | ||
try { | ||
await User.refreshToken() | ||
} | ||
catch (err) { | ||
//SSO integration | ||
// Function to handle token refresh and redirection | ||
const handleTokenRefreshError = (err) => { | ||
//SSO redirection | ||
if (isSSO) { | ||
if (!urlPath.startsWith('/api/sso')) | ||
|
||
if (!router.currentRoute.value.path.startsWith('/api/sso')) | ||
if (err === 'Expired refreshToken') | ||
redirect('/api/sso?tokenError=2') | ||
router.push('/api/sso?tokenError=2') | ||
else | ||
redirect('/api/sso') | ||
router.push('/api/sso') | ||
} | ||
else { | ||
if (!urlPath.startsWith('/login')) | ||
if (!router.currentRoute.value.path.startsWith('/login')) | ||
if (err === 'Expired refreshToken') | ||
redirect('/login?tokenError=2') | ||
router.push('/login?tokenError=2') | ||
else | ||
redirect('/login') | ||
router.push('/login') | ||
} | ||
} | ||
|
||
router.beforeEach((to, from, next) => { | ||
// Initial token refresh and setup | ||
const initTokenRefresh = async () => { | ||
// Launch refresh token countdown 840000=14min if not on login page | ||
tokenRefreshInterval.value = setInterval(() => { | ||
refreshToken() | ||
.then() | ||
.catch(err => handleTokenRefreshError(err)) | ||
}, 840000) | ||
|
||
// Call refreshToken when loading app and redirect to login if error | ||
try { | ||
await refreshToken() | ||
} | ||
catch (err) { | ||
handleTokenRefreshError(err) | ||
} | ||
} | ||
|
||
// Add navigation guard directly to the router | ||
router.beforeEach((to, from) => { | ||
//SSO Integration | ||
if (isSSO) { | ||
if (to.path === '/api/sso') { | ||
if (User.isAuth()) | ||
next('/') | ||
else if (true) { | ||
if (isAuth()) | ||
return '/' | ||
else { | ||
console.log("router crash") | ||
next('/api/sso') | ||
return '/api/sso' | ||
} | ||
} | ||
else | ||
next() | ||
return true | ||
} | ||
else { | ||
if (to.path === '/login') { | ||
if (User.isAuth()) | ||
next('/') | ||
else | ||
next() | ||
} | ||
else { | ||
next() | ||
if (isAuth()) | ||
return '/' | ||
return true | ||
} | ||
return true | ||
} | ||
}) | ||
|
||
// Initial token refresh | ||
initTokenRefresh() | ||
|
||
// Return cleanup function | ||
return () => { | ||
if (tokenRefreshInterval.value) { | ||
clearInterval(tokenRefreshInterval.value) | ||
} | ||
} | ||
) | ||
} |
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
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 |
---|---|---|
@@ -1,30 +1,33 @@ | ||
import Vue from "vue"; | ||
import { Dark } from "quasar"; | ||
import { createApp } from 'vue'; | ||
import App from './../App.vue'; | ||
import { Dark } from 'quasar'; | ||
|
||
const DarkModeSwitcher = { | ||
install: function(Vue) { | ||
Vue.prototype.toggleDarkMode = function() { | ||
updateDarkMode(!Dark.isActive); | ||
} | ||
} | ||
}; | ||
Vue.use(DarkModeSwitcher); | ||
const app = createApp(App); | ||
|
||
function updateDarkMode(dark = null) { | ||
// using !! to convert it to a boolean is ok in this case, | ||
// because we are checking, if the key exists | ||
let darkmode = !!localStorage.getItem("darkmodeEnabled") || false; | ||
if(dark != null) { | ||
// set mode | ||
darkmode = dark; | ||
} | ||
|
||
Dark.set(darkmode); | ||
if(darkmode) { | ||
localStorage.setItem("darkmodeEnabled", "y"); | ||
} else { | ||
localStorage.removeItem("darkmodeEnabled"); | ||
} | ||
Dark.set(dark !== null ? dark : !!localStorage.getItem("darkmode")); | ||
if (dark !== null) { | ||
localStorage.setItem('darkmode', dark ? 'y' : 'n'); | ||
} else { | ||
localStorage.removeItem('darkmode'); | ||
} | ||
} | ||
|
||
const toggleDarkMode = function() { | ||
updateDarkMode(!Dark.isActive); | ||
}; | ||
|
||
// Initialize dark mode based on local storage value | ||
function initializeDarkMode() { | ||
const darkMode = localStorage.getItem('darkmode'); | ||
if (darkMode === 'y') { | ||
Dark.set(true); | ||
} else if (darkMode === 'n') { | ||
Dark.set(false); | ||
} | ||
} | ||
|
||
updateDarkMode(); | ||
// Call initializeDarkMode when the app is created | ||
initializeDarkMode(); | ||
|
||
export { toggleDarkMode, Dark }; |
Oops, something went wrong.