mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-30 10:27:49 +00:00
Update auth.ts
This commit is contained in:
@@ -33,6 +33,7 @@ interface AuthState {
|
|||||||
loginWithTelegram: (initData: string) => Promise<void>
|
loginWithTelegram: (initData: string) => Promise<void>
|
||||||
loginWithTelegramWidget: (data: TelegramWidgetData) => Promise<void>
|
loginWithTelegramWidget: (data: TelegramWidgetData) => Promise<void>
|
||||||
loginWithEmail: (email: string, password: string) => Promise<void>
|
loginWithEmail: (email: string, password: string) => Promise<void>
|
||||||
|
registerWithEmail: (email: string, password: string, firstName?: string) => Promise<void>
|
||||||
}
|
}
|
||||||
|
|
||||||
// Блокировка для предотвращения race condition при инициализации
|
// Блокировка для предотвращения race condition при инициализации
|
||||||
@@ -260,6 +261,23 @@ export const useAuthStore = create<AuthState>()(
|
|||||||
})
|
})
|
||||||
get().checkAdminStatus()
|
get().checkAdminStatus()
|
||||||
},
|
},
|
||||||
|
|
||||||
|
registerWithEmail: async (email, password, firstName) => {
|
||||||
|
const response = await authApi.registerEmailStandalone({
|
||||||
|
email,
|
||||||
|
password,
|
||||||
|
first_name: firstName,
|
||||||
|
language: navigator.language.split('-')[0] || 'ru',
|
||||||
|
})
|
||||||
|
tokenStorage.setTokens(response.access_token, response.refresh_token)
|
||||||
|
set({
|
||||||
|
accessToken: response.access_token,
|
||||||
|
refreshToken: response.refresh_token,
|
||||||
|
user: response.user,
|
||||||
|
isAuthenticated: true,
|
||||||
|
})
|
||||||
|
get().checkAdminStatus()
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
name: 'cabinet-auth',
|
name: 'cabinet-auth',
|
||||||
|
|||||||
Reference in New Issue
Block a user