refactor: auth and wayfern

This commit is contained in:
zhom
2026-04-25 16:30:59 +04:00
parent 658d428a62
commit a322c97d64
13 changed files with 231 additions and 441 deletions
+5 -15
View File
@@ -7,8 +7,7 @@ interface UseCloudAuthReturn {
user: CloudUser | null;
isLoggedIn: boolean;
isLoading: boolean;
requestOtp: (email: string, captchaToken: string) => Promise<string>;
verifyOtp: (email: string, code: string) => Promise<CloudAuthState>;
exchangeDeviceCode: (code: string) => Promise<CloudAuthState>;
logout: () => Promise<void>;
refreshProfile: () => Promise<CloudUser>;
}
@@ -50,17 +49,9 @@ export function useCloudAuth(): UseCloudAuthReturn {
};
}, [loadUser]);
const requestOtp = useCallback(
(email: string, captchaToken: string): Promise<string> => {
return invoke<string>("cloud_request_otp", { email, captchaToken });
},
[],
);
const verifyOtp = useCallback(
async (email: string, code: string): Promise<CloudAuthState> => {
const state = await invoke<CloudAuthState>("cloud_verify_otp", {
email,
const exchangeDeviceCode = useCallback(
async (code: string): Promise<CloudAuthState> => {
const state = await invoke<CloudAuthState>("cloud_exchange_device_code", {
code,
});
setAuthState(state);
@@ -88,8 +79,7 @@ export function useCloudAuth(): UseCloudAuthReturn {
user: authState?.user ?? null,
isLoggedIn: authState !== null,
isLoading,
requestOtp,
verifyOtp,
exchangeDeviceCode,
logout,
refreshProfile,
};