Finally figured out SQLAlchemy and started to re-write some of the APIs. The UI will completely handle by JS with Vue. There will be no more templating from flask to minimize the resource usage ;)

This commit is contained in:
Donald Zou
2024-01-10 01:42:19 -05:00
parent 864f82ba11
commit ba2bcaba07
5 changed files with 191 additions and 20 deletions

View File

@@ -3,6 +3,15 @@ import {cookie} from "../utilities/cookie.js";
import Index from "@/views/index.vue"
import Signin from "@/views/signin.vue";
import ConfigurationList from "@/views/configurationList.vue";
import {fetchGet} from "@/utilities/fetch.js";
const checkAuth = async () => {
let result = false
await fetchGet("/api/validateAuthentication", {}, (res) => {
result = res.status
});
return result;
}
const router = createRouter({
history: createWebHashHistory(),
@@ -26,9 +35,9 @@ const router = createRouter({
]
});
router.beforeEach((to, from, next) => {
router.beforeEach(async (to, from, next) => {
if (to.meta.requiresAuth){
if (cookie.getCookie("authToken")){
if (cookie.getCookie("authToken") && await checkAuth()){
next()
}else{
next("/signin")

View File

@@ -1,6 +1,6 @@
export const fetchGet = async (url, params=undefined, callback=undefined) => {
const urlSearchParams = new URLSearchParams(params);
await fetch(`${url}?${urlSearchParams.toString()}}`, {
await fetch(`${url}?${urlSearchParams.toString()}`, {
headers: {
"content-type": "application/json"
}

View File

@@ -15,7 +15,7 @@ export default defineConfig({
},
server:{
proxy: {
'/api': 'http://178.128.231.4:10086/'
'/api': 'http://127.0.0.1:10086/'
}
}
})