diff --git a/frontend/src/pages/guest/FrontDoor.vue b/frontend/src/pages/guest/FrontDoor.vue index e90eb28..1aaaf06 100644 --- a/frontend/src/pages/guest/FrontDoor.vue +++ b/frontend/src/pages/guest/FrontDoor.vue @@ -57,8 +57,8 @@ export default { }, methods: { trySigninWithEmail() { - // Prevent the page from refreshing on form submission - event.preventDefault(); + // Prevent the page from refreshing on form submission + event.preventDefault() this.message = null if (this.email === null || this.email.length < 1) { this.message = this.$t('Please type in your email') diff --git a/frontend/src/pages/guest/SigninWithEmailAndPassword.vue b/frontend/src/pages/guest/SigninWithEmailAndPassword.vue index 17a02ab..3f4e1d0 100644 --- a/frontend/src/pages/guest/SigninWithEmailAndPassword.vue +++ b/frontend/src/pages/guest/SigninWithEmailAndPassword.vue @@ -79,12 +79,12 @@ export default { UserAuthApi.signinByEmail(this.email, this.password) .then((response) => { // Extract the necessary data from the response - const { access_token, refresh_token, expires_in } = response.data; + const { access_token, refresh_token, expires_in } = response.data // Save tokens and expiration time in localStorage - localStorage.setItem('access_token', access_token); - localStorage.setItem('refresh_token', refresh_token); - localStorage.setItem('expires_in', expires_in); + localStorage.setItem('access_token', access_token) + localStorage.setItem('refresh_token', refresh_token) + localStorage.setItem('expires_in', expires_in) let signinAction = response.data.signin_result switch (signinAction) { diff --git a/frontend/src/utils/backend/axios.js b/frontend/src/utils/backend/axios.js index c25eeb5..ed9678b 100644 --- a/frontend/src/utils/backend/axios.js +++ b/frontend/src/utils/backend/axios.js @@ -1,5 +1,5 @@ import axios from 'axios' -import { jwtDecode } from 'jwt-decode'; +import { jwtDecode } from 'jwt-decode' const backendAxios = axios.create({ baseURL: '', @@ -34,8 +34,8 @@ backendAxios.interceptors.request.use( let accessToken = localStorage.getItem('access_token') let refreshToken = localStorage.getItem('refresh_token') // Fix: handle the case where localStorage returns 'null' as a string - if (accessToken === 'null') accessToken = null; - if (refreshToken === 'null') refreshToken = null; + if (accessToken === 'null') accessToken = null + if (refreshToken === 'null') refreshToken = null // Check if the access token is expired if (accessToken == null || refreshToken == null) { @@ -44,12 +44,16 @@ backendAxios.interceptors.request.use( if (isTokenExpired(accessToken)) { try { // If access token is expired, refresh it using the refresh token - const response = await axios.post('/api/user/signin/refresh-token', {}, { - headers: { - Authorization: `Bearer ${refreshToken}`, - 'Content-Type': 'application/json' + const response = await axios.post( + '/api/user/signin/refresh-token', + {}, + { + headers: { + Authorization: `Bearer ${refreshToken}`, + 'Content-Type': 'application/json' + } } - }); + ) accessToken = response.data.access_token refreshToken = response.data.refresh_token