Skip to content
Snippets Groups Projects
Commit 3c24b251 authored by simon.mellerin's avatar simon.mellerin
Browse files

#8 - fixes

parent d8004ae4
No related branches found
No related tags found
1 merge request!11#8 - Use XMLHttpRequest instead of fetch
Pipeline #10146 failed
...@@ -47,3 +47,8 @@ export type Credentials = { ...@@ -47,3 +47,8 @@ export type Credentials = {
username: string username: string
password: string password: string
} }
export type HttpResponse = {
status: number
data: string
}
import type { Credentials } from "@/declarations"; import type { Credentials, HttpResponse } from "@/declarations";
/** /**
* Perform XMLHttpRequest as Promise * Perform XMLHttpRequest as Promise
...@@ -49,8 +49,3 @@ export function httpFetch( ...@@ -49,8 +49,3 @@ export function httpFetch(
xhr.send(options?.body); xhr.send(options?.body);
}); });
} }
interface HttpResponse {
status: number
data: string
}
<template> <template>
<OcLayoutBiColumn :is-authenticated="accountStore.isAuthenticated()" :community="community"> <OcLayoutBiColumn :is-authenticated="accountStore.isAuthenticated" :community="community">
<div class="w-11/12 md:w-10/12 xl:w-7/12"> <div class="w-11/12 md:w-10/12 xl:w-7/12">
<img src="/logo.png" class="h-16" /> <img src="/logo.png" class="h-16" />
<p class="font-title font-bold text-5xl uppercase text-primary mb-4">Open Common</p> <p class="font-title font-bold text-5xl uppercase text-primary mb-4">Open Common</p>
......
<template> <template>
<OcLayoutBiColumn :is-authenticated="accountStore.isAuthenticated()"> <OcLayoutBiColumn :is-authenticated="accountStore.isAuthenticated">
<div class="w-11/12 md:w-10/12 xl:w-7/12"> <div class="w-11/12 md:w-10/12 xl:w-7/12">
<img src="/logo.png" class="h-16" /> <img src="/logo.png" class="h-16" />
<p class="font-title font-bold text-5xl uppercase text-primary mb-4">Open Common</p> <p class="font-title font-bold text-5xl uppercase text-primary mb-4">Open Common</p>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<img src="/logo-text.png" class="h-20" /> <img src="/logo-text.png" class="h-20" />
<h1 class="sr-only">Open Common</h1> <h1 class="sr-only">Open Common</h1>
<div> <div>
<OcTopMenu mode="light" :is-authenticated="accountStore.isAuthenticated()" /> <OcTopMenu mode="light" :is-authenticated="accountStore.isAuthenticated" />
</div> </div>
</nav> </nav>
<div class="w-11/12 md:w-10/12 lg:w-9/12 xl:w-7/12 mx-auto mb-10 flex flex-col items-start"> <div class="w-11/12 md:w-10/12 lg:w-9/12 xl:w-7/12 mx-auto mb-10 flex flex-col items-start">
......
<template> <template>
<OcLayoutBiColumn :is-authenticated="accountStore.isAuthenticated()"> <OcLayoutBiColumn :is-authenticated="accountStore.isAuthenticated">
<div class="w-11/12 md:w-10/12 xl:w-7/12"> <div class="w-11/12 md:w-10/12 xl:w-7/12">
<img src="/logo.png" class="h-16" /> <img src="/logo.png" class="h-16" />
<p class="font-title font-bold text-5xl uppercase text-primary mb-4">Open Common</p> <p class="font-title font-bold text-5xl uppercase text-primary mb-4">Open Common</p>
......
<template> <template>
<OcLayoutSimple :is-authenticated="accountStore.isAuthenticated()"> <OcLayoutSimple :is-authenticated="accountStore.isAuthenticated">
<div class="shadow-lg p-8"> <div class="shadow-lg p-8">
<h1 class="text-xl font-bold mb-8">{{ t('profile.profile') }}</h1> <h1 class="text-xl font-bold mb-8">{{ t('profile.profile') }}</h1>
<ul class=" list-disc pl-4"> <ul class=" list-disc pl-4">
......
<template> <template>
<OcLayoutBiColumn :is-authenticated="accountStore.isAuthenticated()"> <OcLayoutBiColumn :is-authenticated="accountStore.isAuthenticated">
<div class="w-11/12 md:w-10/12"> <div class="w-11/12 md:w-10/12">
<h1 class="font-title font-bold text-5xl uppercase text-primary mb-8">{{ t('register.requestAccount') }}</h1> <h1 class="font-title font-bold text-5xl uppercase text-primary mb-8">{{ t('register.requestAccount') }}</h1>
...@@ -7,13 +7,13 @@ ...@@ -7,13 +7,13 @@
{{ t('register.error') }} {{ t('register.error') }}
</Message> </Message>
<OcRegisterForm v-if="!accountStore.isAuthenticated()" @registration-request="registrationRequest" /> <OcRegisterForm v-if="!accountStore.isAuthenticated" @registration-request="registrationRequest" />
<Message v-else severity="warn"> <Message v-else severity="warn">
{{ t('connection.alreadyLoggedIn', { login: accountStore.infos?.loginID }) }} {{ t('connection.alreadyLoggedIn', { login: accountStore.infos?.loginID }) }}
</Message> </Message>
</div> </div>
<Dialog v-model:visible="showConfirmation" modal :style="{ width: '25rem' }"> <Dialog v-model:visible="showConfirmation" modal :style="{ width: '25rem' }" :closable="false">
<div class="flex flex-col items-center justify-center"> <div class="flex flex-col items-center justify-center">
<i class="fa-solid fa-circle-check text-6xl text-center text-primary mb-6"></i> <i class="fa-solid fa-circle-check text-6xl text-center text-primary mb-6"></i>
<p class="text-center mb-6">{{ t('register.confirmation.1') }}</p> <p class="text-center mb-6">{{ t('register.confirmation.1') }}</p>
......
...@@ -57,7 +57,7 @@ router.beforeResolve((to) => { ...@@ -57,7 +57,7 @@ router.beforeResolve((to) => {
router.beforeEach(async () => { router.beforeEach(async () => {
const accountStore = useAccountStore() const accountStore = useAccountStore()
if (accountStore.isAuthenticated() && accountStore.profile === null) { if (accountStore.isAuthenticated && accountStore.profile === null) {
const { infos, profile } = await getProfileInfos(accountStore.auth) const { infos, profile } = await getProfileInfos(accountStore.auth)
accountStore.profile = profile accountStore.profile = profile
......
...@@ -32,7 +32,7 @@ export async function insertRegistrationRequest(login: string, firstName: string ...@@ -32,7 +32,7 @@ export async function insertRegistrationRequest(login: string, firstName: string
oct:loginID '${login}'; oct:loginID '${login}';
dct:identifier '${uuid}'; dct:identifier '${uuid}';
foaf:givenName '${givenName}'; foaf:givenName '${givenName}';
foaf:familyName '${firstName}'; foaf:familyName '${firstName}'.
} }
`, `,
{ {
......
import type { Credentials, OcMemberInfos, OcPerson } from '@/declarations' import type { Credentials, OcMemberInfos, OcPerson } from '@/declarations'
import { defineStore } from 'pinia' import { defineStore } from 'pinia'
import { ref, watch } from 'vue' import { computed, ref, watch } from 'vue'
interface AccountState { interface AccountState {
auth?: Credentials auth?: Credentials
...@@ -25,13 +25,14 @@ export const useAccountStore = defineStore<string, AccountState>('account', () = ...@@ -25,13 +25,14 @@ export const useAccountStore = defineStore<string, AccountState>('account', () =
const infos = ref(null) const infos = ref(null)
const profile = ref(null) const profile = ref(null)
const isAuthenticated = () => auth.value !== undefined const isAuthenticated = computed(() => auth.value !== undefined)
watch(auth, (auth: Credentials) => { watch(auth, (auth: Credentials) => {
if (auth) { if (auth) {
localStorage.setItem("token", btoa(`${auth.username}:${auth.password}`)); localStorage.setItem("token", btoa(`${auth.username}:${auth.password}`));
} else {
localStorage.removeItem("token")
} }
localStorage.removeItem("token")
}) })
return { return {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment