login projects 2

This commit is contained in:
Florinda
2024-10-21 18:10:34 +02:00
parent ae32a63def
commit aa466491c2
2 changed files with 5 additions and 11 deletions

View File

@@ -48,7 +48,7 @@ var auth = createAuth({
}
});
axios.defaults.baseURL = 'http://localhost:8081' //import.meta.env.VITE_BACKEND_URL;//'http://localhost:8081'
axios.defaults.baseURL = import.meta.env.VITE_BACKEND_URL;//'http://localhost:8081'
console.log(import.meta.env.VITE_BACKEND_URL);
const app = createApp(App);

View File

@@ -3,6 +3,7 @@ import { useLayout } from '@/layout/composables/layout';
import { useAuth } from '@websanova/vue-auth/src/v3.js';
import Message from 'primevue/message';
import { computed, ref } from 'vue';
import { useRouter } from 'vue-router';
const auth = useAuth();
@@ -12,6 +13,7 @@ const username = ref('');
const password = ref('');
const error = ref('');
const visible = ref(false);
const router = useRouter();
const logoUrl = computed(() => {
return `/layout/images/${isDarkTheme ? 'logo-white' : 'logo-dark'}.svg`;
@@ -24,21 +26,13 @@ const login = async () => {
"username":username.value,
"password":password.value
},
//redirect:'/projects',
fetchUser: true,
//url: '/api/auth/login'
fetchUser: true
}).then((response) => {
console.log("1 user :" , response.data.data);
// Controlla se selectedProject è nullo o un oggetto vuoto
if (!response.data.data.selectedProject) {
// Se selectedProject è nullo o vuoto, reindirizza a '/projects'
console.log("selP null" , response.data.data);
router.push({ name: 'project-list' });
router.push({ name: 'projects-list' });
} else {
// Se selectedProject è nullo o vuoto, reindirizza a '/projects'
console.log("selP not null" , response.data.data);
// Altrimenti, reindirizza a '/scenarios'
router.push({ name: 'scenario-list' });
}