mirror of
https://github.com/YunoHost/yunohost-portal.git
synced 2024-09-03 20:06:23 +02:00
reflect User composable changes to default layout and edit page
This commit is contained in:
parent
623d3b4483
commit
11d303a8e6
2 changed files with 17 additions and 11 deletions
|
@ -1,7 +1,10 @@
|
|||
<script setup lang="ts">
|
||||
import type { User } from '@/composables/states'
|
||||
|
||||
const { t } = useI18n()
|
||||
const isLoggedIn = useIsLoggedIn()
|
||||
const { userData: me } = await useUserInfo()
|
||||
const settings = await useSettings()
|
||||
const user = await useUser<User | null>()
|
||||
const skipLink: Ref<HTMLLinkElement | null> = ref(null)
|
||||
const colorMode = useColorMode()
|
||||
const themes = [
|
||||
|
@ -56,9 +59,10 @@ async function logout() {
|
|||
const { error } = await useApi('/logout')
|
||||
|
||||
if (!error.value) {
|
||||
// FIXME : meh, turns out the cookie is still valid after successfully calling the route for some reason ... !?
|
||||
// Delete user infos
|
||||
user.value = null
|
||||
isLoggedIn.value = false
|
||||
await navigateTo('/login')
|
||||
await navigateTo(settings.value.public ? '/' : '/login')
|
||||
} else {
|
||||
// FIXME : display an error or something
|
||||
}
|
||||
|
@ -87,10 +91,10 @@ async function logout() {
|
|||
|
||||
<div>
|
||||
<h2 class="text-2xl font-extrabold leading-none tracking-tight">
|
||||
{{ me.username }}
|
||||
{{ user?.username || t('visitor') }}
|
||||
</h2>
|
||||
<h3>{{ me.fullname }}</h3>
|
||||
<h4 class="opacity-50">{{ me.mail }}</h4>
|
||||
<h3 v-if="user">{{ user.fullname }}</h3>
|
||||
<h4 v-if="user" class="opacity-50">{{ user.mail }}</h4>
|
||||
</div>
|
||||
|
||||
<!-- FIXME temp -->
|
||||
|
@ -106,10 +110,12 @@ async function logout() {
|
|||
</div>
|
||||
|
||||
<YButton
|
||||
v-if="isLoggedIn"
|
||||
icon="mdi:logout"
|
||||
:text="t('logout')"
|
||||
@click.prevent="logout"
|
||||
/>
|
||||
<YButton v-else icon="mdi:login" :text="t('login')" to="/login" />
|
||||
</div>
|
||||
</slot>
|
||||
</header>
|
||||
|
|
|
@ -3,10 +3,10 @@ import { useForm } from 'vee-validate'
|
|||
import { toTypedSchema } from '@vee-validate/yup'
|
||||
import * as yup from 'yup'
|
||||
import { pick, exclude } from '@/utils/common'
|
||||
import type { UserData } from '@/composables/api'
|
||||
import type { User } from '@/composables/states'
|
||||
|
||||
const { t } = useI18n()
|
||||
const { userData, update } = await useUserInfo()
|
||||
const user = await useUser()
|
||||
|
||||
const loading: Ref<boolean | null> = ref(false)
|
||||
const feedback: Ref<{
|
||||
|
@ -44,7 +44,7 @@ const { handleSubmit, setFieldError, resetForm, meta } = useForm({
|
|||
currentpassword: '',
|
||||
newpassword: '',
|
||||
confirmpassword: '',
|
||||
...pick(userData.value, 'fullname', 'mailalias', 'mailforward'),
|
||||
...pick(user.value, 'fullname', 'mailalias', 'mailforward'),
|
||||
},
|
||||
})
|
||||
|
||||
|
@ -63,7 +63,7 @@ const onSubmit = handleSubmit(async (form) => {
|
|||
loading.value = true
|
||||
|
||||
const { error, data } = await useApi<
|
||||
Pick<UserData, 'fullname' | 'mailalias' | 'mailforward'>
|
||||
Pick<User, 'fullname' | 'mailalias' | 'mailforward'>
|
||||
>('/update', {
|
||||
method: 'PUT',
|
||||
body: exclude(form, 'confirmpassword'),
|
||||
|
@ -89,7 +89,7 @@ const onSubmit = handleSubmit(async (form) => {
|
|||
return navigateTo('/login')
|
||||
}
|
||||
|
||||
update(data.value)
|
||||
Object.assign(user.value, data)
|
||||
resetForm({
|
||||
values: {
|
||||
...data.value,
|
||||
|
|
Loading…
Add table
Reference in a new issue