Merge branch 'main' into Training-Report
This commit is contained in:
2
ui/.env.example
Normal file
2
ui/.env.example
Normal file
@@ -0,0 +1,2 @@
|
||||
# SITE SETTINGS
|
||||
BASE_URL=
|
||||
@@ -24,9 +24,10 @@ const userStore = useUserStore();
|
||||
// console.log(data);
|
||||
// userStore.user = data;
|
||||
// });
|
||||
const APIHOST = import.meta.env.VITE_APIHOST;
|
||||
|
||||
async function logout() {
|
||||
await fetch(`${import.meta.env.VITE_APIHOST}/logout`, {
|
||||
await fetch(`${APIHOST}/logout`, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
});
|
||||
@@ -112,7 +113,7 @@ function formatDate(dateStr) {
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
|
||||
<a v-else href="https://aj17thdevapi.nexuszone.net/login">Login</a>
|
||||
<a v-else :href="APIHOST+'/login'">Login</a>
|
||||
</div>
|
||||
</div>
|
||||
<Separator></Separator>
|
||||
|
||||
@@ -40,6 +40,9 @@ const router = createRouter({
|
||||
]
|
||||
})
|
||||
|
||||
const addr = import.meta.env.VITE_APIHOST;
|
||||
|
||||
|
||||
router.beforeEach(async (to) => {
|
||||
const user = useUserStore()
|
||||
|
||||
@@ -48,13 +51,13 @@ router.beforeEach(async (to) => {
|
||||
await user.loadUser();
|
||||
}
|
||||
|
||||
// // Not logged in
|
||||
// if (to.meta.requiresAuth && !user.isLoggedIn) {
|
||||
// // Redirect back to original page after login
|
||||
// const redirectUrl = encodeURIComponent(window.location.origin + to.fullPath)
|
||||
// window.location.href = `https://aj17thdevapi.nexuszone.net/login?redirect=${redirectUrl}`
|
||||
// return false // Prevent Vue Router from continuing
|
||||
// }
|
||||
// Not logged in
|
||||
if (to.meta.requiresAuth && !user.isLoggedIn) {
|
||||
// Redirect back to original page after login
|
||||
const redirectUrl = encodeURIComponent(window.location.origin + to.fullPath)
|
||||
window.location.href = `${addr}/login?redirect=${redirectUrl}`
|
||||
return false // Prevent Vue Router from continuing
|
||||
}
|
||||
|
||||
|
||||
// // Must be a member
|
||||
|
||||
Reference in New Issue
Block a user