diff --git a/src/Login.vue b/src/Login.vue
index be9cd86..1552572 100644
--- a/src/Login.vue
+++ b/src/Login.vue
@@ -8,58 +8,47 @@
-
Logged in as: {{ userData.is_admin ? "Admin" : "" }} {{ userData.username }}
+
Logged in as: {{ userData.is_admin ? 'Admin' : '' }} {{ userData.username }}
-
+
diff --git a/src/Router.vue b/src/Router.vue
index e818368..3518d2b 100644
--- a/src/Router.vue
+++ b/src/Router.vue
@@ -1,12 +1,12 @@
-
+
@@ -16,7 +16,22 @@ import Button from 'primevue/button'
import Dialog from 'primevue/dialog'
import Login from './Login.vue'
+import { useUserData } from './user'
import { ref } from 'vue'
+const userRef = useUserData()
+
const visible = ref(false)
+
+function displayUsername(): string {
+ const authenticated = userRef.value.authenticated
+ if (authenticated) {
+ return userRef.value.username
+ }
+ return 'Login'
+}
+
+function loginCallback(): void {
+ visible.value = false;
+}
diff --git a/src/TableEditor.vue b/src/TableEditor.vue
index 1c63720..3338dea 100644
--- a/src/TableEditor.vue
+++ b/src/TableEditor.vue
@@ -24,7 +24,10 @@
Status:
-
+
@@ -45,8 +48,20 @@
Edit Details
-
-
+
+
@@ -77,7 +92,8 @@
margin: 5px;
}
-.active-foundry-stats {}
+.active-foundry-stats {
+}
.inactive-foundry-stats {
display: none;
@@ -114,9 +130,9 @@ const foundryStatus = reactive({
})
const currentUser = ref({
- username: "None",
- authenticated: "False",
- is_admin: "False"
+ username: 'None',
+ authenticated: 'False',
+ is_admin: 'False',
})
const version = ref(12)
@@ -135,7 +151,7 @@ onMounted(() => {
loadTable()
- axios.get('/api/auth/user').then((resp) => currentUser.value = resp.data)
+ axios.get('/api/auth/user').then((resp) => (currentUser.value = resp.data))
hostname.value = location.host
})
@@ -225,7 +241,7 @@ function stopTable() {
})
}
-function deleteTable() { }
+function deleteTable() {}
function isTableLoading() {
return table.active && !foundryStatus.running
diff --git a/src/main.ts b/src/main.ts
index ba3f4f7..ba67f3e 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -14,7 +14,7 @@ const routes = [
{ name: 'home', path: '/', component: TableManager },
{ name: 'edit', path: '/edit/:id', component: TableEditor },
{ name: 'new', path: '/new', component: CreateTable },
- { name: 'login', path: '/login', component: Login}
+ { name: 'login', path: '/login', component: Login },
]
const router = createRouter({
diff --git a/src/user.ts b/src/user.ts
index 7e5f401..1bab0d8 100644
--- a/src/user.ts
+++ b/src/user.ts
@@ -1,5 +1,5 @@
import axios from 'axios'
-import { ref, computed, onMounted } from "vue"
+import { ref, computed, onMounted } from 'vue'
export interface User {
username: string
@@ -7,7 +7,7 @@ export interface User {
authenticated: boolean
}
-const $current_user = ref({ username: "username", is_admin: false, authenticated: false })
+const $current_user = ref({ username: 'username', is_admin: false, authenticated: false })
export const current_user = computed((): User => {
return $current_user.value
})
@@ -18,13 +18,15 @@ function loadCurrentUser(): void {
})
}
-export function userUserData(): void {
+export function useUserData(): void {
onMounted(() => {
loadCurrentUser()
})
+
+ return $current_user
}
-export function loginUser(username: string, password: string): void {
+export function login(username: string, password: string): void {
axios.post('/api/auth/login', { username, password }).then((resp) => {
$current_user.value = resp.data
})
@@ -37,3 +39,10 @@ export function logout(): void {
})
}
}
+
+export function resetPassword(password: string): void {
+ axios.post(`/api/auth/user/${$current_user.value.id}`, {
+ username: $current_user.value.username,
+ password,
+ })
+}