fix : redirige sur le login sur une 401 et reset du auth state + doc + timeout du toaster
This commit is contained in:
Generated
+17
-6
@@ -4,10 +4,13 @@
|
|||||||
<option name="autoReloadType" value="SELECTIVE" />
|
<option name="autoReloadType" value="SELECTIVE" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="7c107abe-5995-4428-8429-b146aaca8386" name="Changes" comment="fix : script de déploiement">
|
<list default="true" id="7c107abe-5995-4428-8429-b146aaca8386" name="Changes" comment="feat : ajout plus d'information sur la liste des réceptions côté front sur la page d'accueil">
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/config/reference.php" beforeDir="false" afterPath="$PROJECT_DIR$/config/reference.php" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/config/reference.php" beforeDir="false" afterPath="$PROJECT_DIR$/config/reference.php" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/frontend/pages/index.vue" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/pages/index.vue" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/frontend/composables/useApi.ts" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/composables/useApi.ts" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/frontend/nuxt.config.ts" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/nuxt.config.ts" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/frontend/stores/auth.ts" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/stores/auth.ts" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@@ -266,7 +269,7 @@
|
|||||||
<workItem from="1768374298711" duration="12403000" />
|
<workItem from="1768374298711" duration="12403000" />
|
||||||
<workItem from="1768460547451" duration="26946000" />
|
<workItem from="1768460547451" duration="26946000" />
|
||||||
<workItem from="1768547023783" duration="11371000" />
|
<workItem from="1768547023783" duration="11371000" />
|
||||||
<workItem from="1768894030675" duration="53874000" />
|
<workItem from="1768894030675" duration="54763000" />
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00001" summary="feat : Ajout de pinia, création de la table weight et reception mise en place du système de step pour les receptions (WIP)">
|
<task id="LOCAL-00001" summary="feat : Ajout de pinia, création de la table weight et reception mise en place du système de step pour les receptions (WIP)">
|
||||||
<option name="closed" value="true" />
|
<option name="closed" value="true" />
|
||||||
@@ -508,7 +511,15 @@
|
|||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1769098182184</updated>
|
<updated>1769098182184</updated>
|
||||||
</task>
|
</task>
|
||||||
<option name="localTasksCounter" value="31" />
|
<task id="LOCAL-00031" summary="feat : ajout plus d'information sur la liste des réceptions côté front sur la page d'accueil">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1769098861988</created>
|
||||||
|
<option name="number" value="00031" />
|
||||||
|
<option name="presentableId" value="LOCAL-00031" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1769098861988</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="32" />
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="TypeScriptGeneratedFilesManager">
|
<component name="TypeScriptGeneratedFilesManager">
|
||||||
@@ -558,7 +569,6 @@
|
|||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="VcsManagerConfiguration">
|
<component name="VcsManagerConfiguration">
|
||||||
<MESSAGE value="feat : update du fichier AGENTS.md" />
|
|
||||||
<MESSAGE value="feat : update du fichier README.md et CHANGELOG.md" />
|
<MESSAGE value="feat : update du fichier README.md et CHANGELOG.md" />
|
||||||
<MESSAGE value="fix : correction du useApi pour qu'il n'y ait plus de retry lors d'une erreur 500 par exemple" />
|
<MESSAGE value="fix : correction du useApi pour qu'il n'y ait plus de retry lors d'une erreur 500 par exemple" />
|
||||||
<MESSAGE value="test : ajout de TU sur les services et providers" />
|
<MESSAGE value="test : ajout de TU sur les services et providers" />
|
||||||
@@ -583,7 +593,8 @@
|
|||||||
<MESSAGE value="fix : doc et script de déploiement" />
|
<MESSAGE value="fix : doc et script de déploiement" />
|
||||||
<MESSAGE value="fix : gitea workflow" />
|
<MESSAGE value="fix : gitea workflow" />
|
||||||
<MESSAGE value="fix : script de déploiement" />
|
<MESSAGE value="fix : script de déploiement" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value="fix : script de déploiement" />
|
<MESSAGE value="feat : ajout plus d'information sur la liste des réceptions côté front sur la page d'accueil" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value="feat : ajout plus d'information sur la liste des réceptions côté front sur la page d'accueil" />
|
||||||
</component>
|
</component>
|
||||||
<component name="XSLT-Support.FileAssociations.UIState">
|
<component name="XSLT-Support.FileAssociations.UIState">
|
||||||
<expand />
|
<expand />
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ Vérifier que dans le .env.local, vous avez :
|
|||||||
* JWT_SECRET_KEY (à générer avec la commande php bin/console lexik:jwt:generate-keypair)
|
* JWT_SECRET_KEY (à générer avec la commande php bin/console lexik:jwt:generate-keypair)
|
||||||
* JWT_PUBLIC_KEY
|
* JWT_PUBLIC_KEY
|
||||||
* JWT_PASSPHRASE (à généré dans le conteneur avec la commande php -r "echo bin2hex(random_bytes(32));")
|
* JWT_PASSPHRASE (à généré dans le conteneur avec la commande php -r "echo bin2hex(random_bytes(32));")
|
||||||
* COOKIE_SECURE=0 (en dev 0 et en prod 1)
|
* COOKIE_SECURE=0 (en dev 0 et en prod 1. Si c'est du http, laisser en 0)
|
||||||
|
|
||||||
Vérifier que dans le .env du dossier frontend, vous avez :
|
Vérifier que dans le .env du dossier frontend, vous avez :
|
||||||
* NUXT_PUBLIC_API_BASE="http://localhost:8080/api"
|
* NUXT_PUBLIC_API_BASE="http://localhost:8080/api"
|
||||||
@@ -120,9 +120,3 @@ VALUES ('Mon user', '["ROLE_USER"]', 'Mon mdp hashé');
|
|||||||
Pour suivre les logs en temps réel :
|
Pour suivre les logs en temps réel :
|
||||||
* tail -f var/log/dev.log
|
* tail -f var/log/dev.log
|
||||||
* tail -f var/log/prod.log
|
* tail -f var/log/prod.log
|
||||||
|
|
||||||
|
|
||||||
sudo usermod -aG www-data malio
|
|
||||||
sudo chown -R malio:www-data /var/www/ferme
|
|
||||||
sudo chmod -R g+rwX /var/www/ferme/var
|
|
||||||
sudo chmod -R g+rx /var/www/ferme
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ export const useApi = (): ApiClient => {
|
|||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
const auth = useAuthStore()
|
const auth = useAuthStore()
|
||||||
const nuxtApp = useNuxtApp()
|
const nuxtApp = useNuxtApp()
|
||||||
|
let isHandlingUnauthorized = false
|
||||||
const i18n = nuxtApp.$i18n as
|
const i18n = nuxtApp.$i18n as
|
||||||
| {
|
| {
|
||||||
t: (key: string) => string
|
t: (key: string) => string
|
||||||
@@ -95,7 +96,23 @@ export const useApi = (): ApiClient => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onResponseError({ response, error, options }) {
|
async onResponseError({ response, error, options }) {
|
||||||
|
if (response?.status === 401) {
|
||||||
|
const requestUrl = typeof options?.url === 'string' ? options.url : ''
|
||||||
|
if (!requestUrl.includes('login_check') && !requestUrl.includes('logout')) {
|
||||||
|
if (!isHandlingUnauthorized) {
|
||||||
|
isHandlingUnauthorized = true
|
||||||
|
auth.clearSession()
|
||||||
|
const route = useRoute()
|
||||||
|
if (route.path !== '/login') {
|
||||||
|
await navigateTo('/login')
|
||||||
|
}
|
||||||
|
isHandlingUnauthorized = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const apiOptions = options as ApiFetchOptions<'json'>
|
const apiOptions = options as ApiFetchOptions<'json'>
|
||||||
if (apiOptions?.toast === false) {
|
if (apiOptions?.toast === false) {
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export default defineNuxtConfig({
|
|||||||
},
|
},
|
||||||
toast: {
|
toast: {
|
||||||
settings: {
|
settings: {
|
||||||
timeout: 0,
|
timeout: 10000,
|
||||||
closeOnClick: true,
|
closeOnClick: true,
|
||||||
progressBar: false
|
progressBar: false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,11 @@ export const useAuthStore = defineStore('auth', {
|
|||||||
isAuthenticated: (state) => Boolean(state.user)
|
isAuthenticated: (state) => Boolean(state.user)
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
|
clearSession() {
|
||||||
|
this.user = null
|
||||||
|
this.checked = true
|
||||||
|
this.isLoading = false
|
||||||
|
},
|
||||||
async ensureSession() {
|
async ensureSession() {
|
||||||
if (this.checked) {
|
if (this.checked) {
|
||||||
return this.user
|
return this.user
|
||||||
|
|||||||
Reference in New Issue
Block a user