refactor: implement authentication flow using authHash in unlock hook and update PasskeyModal UI
CI / Generate Certificates (push) Successful in 1m52s
CI / Frontend CI (push) Successful in 1m13s
CI / Backend CI (push) Successful in 1m15s
CI / E2E Tests (push) Has been skipped

This commit is contained in:
me
2026-05-06 13:45:30 +05:30
parent 3b5f140d21
commit 8449377b6d
5 changed files with 162 additions and 81 deletions
+17 -10
View File
@@ -57,7 +57,6 @@ export const useAuth = () => {
}
try {
// try session refresh
const { data: refreshData } = await publicApi.post(endpoints.REFRESH);
const { data: userData } = await api.get(endpoints.ME, {
headers: { Authorization: `Bearer ${refreshData.access}` },
@@ -71,16 +70,24 @@ export const useAuth = () => {
}, [setMasterKey]);
const unlock = async (password: string) => {
if (!user) return;
if (!user) {
await logout();
return;
}
try {
const { masterKey } = await CryptoUtils.deriveKeyBundle(
password,
user.email,
);
await saveMasterKey(masterKey);
setMasterKey(masterKey);
} catch {}
const { masterKey, authHash } = await CryptoUtils.deriveKeyBundle(
password,
user.email,
);
// Validate password by calling login endpoint
await api.post(endpoints.LOGIN, {
email: user.email,
password: authHash,
});
await saveMasterKey(masterKey);
setMasterKey(masterKey);
};
return {