Added linting and enforced code styling.
This commit is contained in:
parent
8655eae39c
commit
86967b26cd
37 changed files with 3356 additions and 1875 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { defineStore } from 'pinia'
|
||||
import { defineStore } from 'pinia';
|
||||
import axios from 'axios';
|
||||
|
||||
export const useAuthStore = defineStore('auth', {
|
||||
|
|
@ -9,29 +9,39 @@ export const useAuthStore = defineStore('auth', {
|
|||
error: null, // Optional: track errors
|
||||
}),
|
||||
actions: {
|
||||
async checkAuthStatus() {
|
||||
async checkAuthStatus()
|
||||
{
|
||||
this.loading = true;
|
||||
this.error = null;
|
||||
try {
|
||||
try
|
||||
{
|
||||
const res = await axios.get('/auth/check-auth');
|
||||
if (res.data.isAuthenticated) {
|
||||
if (res.data.isAuthenticated)
|
||||
{
|
||||
this.isAuthenticated = true;
|
||||
this.user = res.data.user;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
this.isAuthenticated = false;
|
||||
this.user = null;
|
||||
}
|
||||
} catch (error) {
|
||||
}
|
||||
catch (error)
|
||||
{
|
||||
console.error('Failed to check authentication status:', error);
|
||||
this.error = 'Could not verify login status.';
|
||||
this.isAuthenticated = false;
|
||||
this.user = null;
|
||||
} finally {
|
||||
}
|
||||
finally
|
||||
{
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
// Action to manually set user as logged out (e.g., after logout)
|
||||
logout() {
|
||||
logout()
|
||||
{
|
||||
this.isAuthenticated = false;
|
||||
this.user = null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue