implemented authentication with sidebase/nuxt-auth

This commit is contained in:
Johanna Kuehner
2024-03-11 18:19:11 +01:00
parent 7c19ee9215
commit 6d6b36bdd9
34 changed files with 12861 additions and 2097 deletions

View File

@ -50,6 +50,7 @@ import { ref } from 'vue';
import Axios from '../axios.config.js';
import clientsideConfig from '../clientsideConfig.js';
const { signIn } = useAuth()
const router = useRouter();
const darkMode = ref(true);
const isError = ref(false);
@ -62,13 +63,14 @@ const handleLogin = async () => {
const username = document.getElementById('username-input').value;
const password = document.getElementById('password-input').value;
const requestBody = {
//const requestBody = {
const credentials = {
username: username,
password: password,
}
try {
let res = await Axios.post(`https://${clientsideConfig.url}:${clientsideConfig.port}/api/login`, requestBody);
/*let res = await Axios.post(`https://${clientsideConfig.url}:${clientsideConfig.port}/api/login`, requestBody);
const sessionToken = useCookie('token', {maxAge: 604800, sameSite: true});
sessionToken.value = res.data.token;
@ -80,7 +82,10 @@ const handleLogin = async () => {
console.log(res.data.message)
// sucessfully logged in
router.push('/home')
router.push('/home')*/
let res = await signIn( credentials, { callbackUrl: '/home' })
console.log("res", res)
} catch (err) {
// handle the error
console.log(err.response.statusText)