Change the structure

This commit is contained in:
2025-11-23 21:33:09 +03:00
Unverified
parent 0f4256edad
commit 7d254b5658
36 changed files with 1261 additions and 184 deletions
+4 -4
View File
@@ -5,7 +5,7 @@ import { useImmer } from "use-immer";
import type { LoginRequest } from "@/core/types";
import { useUserStore } from "@/state/user";
import { MaterialButton } from "@/utils/material";
import { ensureKeysOnLogin, deriveAuthSecret, login } from "@/core/api/account";
import api from "@/core/api";
import { AuthTextField, type AuthTextFieldHandle } from "./AuthTextField";
import { initialize, isSupported, startElectronReceiver, subscribe } from "@/core/push-notifications/push-notifications";
import { isElectron } from "@/core/electron/electron";
@@ -79,18 +79,18 @@ export function LoginForm({ onSwitchMode }: LoginFormProps) {
setIsLoading(true);
try {
const derived = await deriveAuthSecret(username, password);
const derived = await api.user.auth.deriveAuthSecret(username, password);
const request: LoginRequest = {
username: username,
password: derived
}
try {
const data = await login(request);
const data = await api.user.auth.login(request);
setUser(data.token, data.user);
try {
await ensureKeysOnLogin(password, data.token);
await api.user.auth.ensureKeysOnLogin(password, data.token);
} catch (e) {
console.error("Key setup failed:", e);
}