From 2519fdcee28d381fb5bc8aa94179b34b929737dc Mon Sep 17 00:00:00 2001 From: Egor Date: Sun, 25 Jan 2026 09:25:56 +0300 Subject: [PATCH] Update auth.ts --- src/store/auth.ts | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/store/auth.ts b/src/store/auth.ts index 3f6979c..f62dc2f 100644 --- a/src/store/auth.ts +++ b/src/store/auth.ts @@ -1,6 +1,6 @@ import { create } from 'zustand' import { persist } from 'zustand/middleware' -import type { User } from '../types' +import type { RegisterResponse, User } from '../types' import { authApi } from '../api/auth' import { apiClient } from '../api/client' import { tokenStorage, isTokenValid, tokenRefreshManager } from '../utils/token' @@ -33,7 +33,7 @@ interface AuthState { loginWithTelegram: (initData: string) => Promise loginWithTelegramWidget: (data: TelegramWidgetData) => Promise loginWithEmail: (email: string, password: string) => Promise - registerWithEmail: (email: string, password: string, firstName?: string, referralCode?: string) => Promise + registerWithEmail: (email: string, password: string, firstName?: string, referralCode?: string) => Promise } // Блокировка для предотвращения race condition при инициализации @@ -263,6 +263,8 @@ export const useAuthStore = create()( }, registerWithEmail: async (email, password, firstName, referralCode) => { + // Registration now returns message, not tokens + // User must verify email before they can login const response = await authApi.registerEmailStandalone({ email, password, @@ -270,14 +272,7 @@ export const useAuthStore = create()( language: navigator.language.split('-')[0] || 'ru', referral_code: referralCode, }) - tokenStorage.setTokens(response.access_token, response.refresh_token) - set({ - accessToken: response.access_token, - refreshToken: response.refresh_token, - user: response.user, - isAuthenticated: true, - }) - get().checkAdminStatus() + return response }, }), {