make login/register reactive
This commit is contained in:
parent
897db1da24
commit
921e53d864
@ -1,6 +1,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { createUser, loginUser } from '../api.js';
|
import { createUser, loginUser,getuserinfo } from '../api.js';
|
||||||
import { useToast } from 'primevue/usetoast';
|
import { useToast } from 'primevue/usetoast';
|
||||||
import PMessage from 'primevue/message';
|
import PMessage from 'primevue/message';
|
||||||
import { useAuth } from '../composables/useAuth.js';
|
import { useAuth } from '../composables/useAuth.js';
|
||||||
@ -27,6 +27,8 @@ async function make_user() {
|
|||||||
password: passwordRegister.value,
|
password: passwordRegister.value,
|
||||||
});
|
});
|
||||||
toast.add({ severity: 'success', summary: 'Succès', detail: 'Utilisateur créé !' });
|
toast.add({ severity: 'success', summary: 'Succès', detail: 'Utilisateur créé !' });
|
||||||
|
isAuth.value = true;
|
||||||
|
userInfo.value = await getuserinfo();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.response && error.response.data) {
|
if (error.response && error.response.data) {
|
||||||
const data = error.response.data;
|
const data = error.response.data;
|
||||||
@ -50,6 +52,8 @@ async function login() {
|
|||||||
password: passwordLogin.value,
|
password: passwordLogin.value,
|
||||||
});
|
});
|
||||||
toast.add({ severity: 'success', summary:`${usernameLogin.value} connecté`});
|
toast.add({ severity: 'success', summary:`${usernameLogin.value} connecté`});
|
||||||
|
isAuth.value = true;
|
||||||
|
userInfo.value = await getuserinfo();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.response && error.response.data) {
|
if (error.response && error.response.data) {
|
||||||
const data = error.response.data;
|
const data = error.response.data;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user