File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import router from './router'
44import authService from './services/auth'
55import './style.css'
66
7- // Настроить axios interceptor для автоматической авторизации
7+
88authService . setupAxiosInterceptor ( )
99
1010const app = createApp ( App )
Original file line number Diff line number Diff line change @@ -35,13 +35,11 @@ const router = createRouter({
3535router . beforeEach ( ( to , from , next ) => {
3636 const isAuthenticated = authService . isAuthenticated ( )
3737
38- // Если маршрут требует авторизации
3938 if ( to . meta . requiresAuth && ! isAuthenticated ) {
4039 next ( '/login' )
4140 return
4241 }
4342
44- // Если пользователь авторизован и пытается зайти на login/register
4543 if ( to . meta . guest && isAuthenticated ) {
4644 next ( '/' )
4745 return
Original file line number Diff line number Diff line change @@ -8,7 +8,6 @@ class AuthService {
88 this . user = JSON . parse ( localStorage . getItem ( 'user' ) || 'null' )
99 }
1010
11- // Регистрация
1211 async register ( email , password ) {
1312 const response = await axios . post ( `${ API_URL } /auth/register` , {
1413 email,
@@ -17,7 +16,6 @@ class AuthService {
1716 return response . data
1817 }
1918
20- // Вход
2119 async login ( email , password ) {
2220 const formData = new URLSearchParams ( )
2321 formData . append ( 'username' , email )
@@ -56,7 +54,6 @@ class AuthService {
5654 }
5755 }
5856
59- // Выход
6057 async logout ( ) {
6158 try {
6259 if ( this . token ) {
@@ -76,17 +73,14 @@ class AuthService {
7673 }
7774 }
7875
79- // Проверка авторизации
8076 isAuthenticated ( ) {
8177 return ! ! this . token
8278 }
8379
84- // Получить пользователя
8580 getUser ( ) {
8681 return this . user
8782 }
8883
89- // Настроить axios interceptor для автоматической авторизации
9084 setupAxiosInterceptor ( ) {
9185 axios . interceptors . request . use (
9286 config => {
Original file line number Diff line number Diff line change 11@import "tailwindcss" ;
22
33@theme {
4- /* Здесь можно добавить кастомные настройки если нужно */
54}
65
76/* Base styles */
You can’t perform that action at this time.
0 commit comments