implemented authentication

This commit is contained in:
Johanna Kuehner
2024-02-29 21:05:08 +01:00
parent 601449d7e0
commit 7c19ee9215
12 changed files with 277 additions and 36 deletions

View File

@ -70,11 +70,17 @@ const handleLogin = async () => {
try {
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;
Axios.defaults.headers.common['Authorization'] = `${username}`;
const userToken = useCookie('user', {maxAge: 604800, sameSite: true});
userToken.value = username;
// something to do with the res?
console.log(res.data)
console.log(sessionToken)
console.log(res.data.message)
// sucessfully logged in
router.push('/')
router.push('/home')
} catch (err) {
// handle the error
console.log(err.response.statusText)