feat: add login page and auth logic

This commit is contained in:
2025-06-10 17:50:28 +05:00
parent 599bf22bda
commit d55a99aafd
6 changed files with 120 additions and 8 deletions

View File

@@ -0,0 +1,22 @@
import api from '../api/api';
import { useUserStore } from '../store/user';
import { Auth } from '../types/auth';
export class AuthService {
static async login(auth: Auth) {
const token = await api.login(auth);
console.log(token);
localStorage.setItem('accessToken', token.accessToken);
}
static async logout() {
useUserStore.getState().removeUser();
localStorage.removeItem('userInfo');
localStorage.removeItem('accessToken');
}
static async refresh() {
const token = await api.refreshToken();
localStorage.setItem('accessToken', token.accessToken);
}
}

View File

@@ -0,0 +1,10 @@
import api from '../api/api';
import { User } from '../types/user';
export class UserService {
static async getProfile(): Promise<User> {
const user = api.getProfile();
return user;
}
}