Skip to content

Commit 21dc89f

Browse files
committed
Add core auth hook and logout handler stubs
Introduces a stub implementation for the core useAuth hook and a core logout handler (useAccountLogout) for open-source builds, allowing proprietary/desktop builds to override via path resolution. Also updates FirstLoginModal to pass confirmPassword to changePasswordOnLogin.
1 parent 5e05340 commit 21dc89f

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
export interface AuthContextType {
2+
session: null;
3+
user: null;
4+
loading: boolean;
5+
error: Error | null;
6+
signOut: () => Promise<void>;
7+
refreshSession: () => Promise<void>;
8+
}
9+
10+
/**
11+
* Core (open-source) auth hook stub.
12+
* Proprietary/desktop builds override this file via path resolution.
13+
*/
14+
export function useAuth(): AuthContextType {
15+
return {
16+
session: null,
17+
user: null,
18+
loading: false,
19+
error: null,
20+
signOut: async () => {},
21+
refreshSession: async () => {},
22+
};
23+
}

frontend/src/core/components/shared/FirstLoginModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export default function FirstLoginModal({ opened, onPasswordChanged, username }:
5252
setLoading(true);
5353
setError('');
5454

55-
await accountService.changePasswordOnLogin(currentPassword, newPassword);
55+
await accountService.changePasswordOnLogin(currentPassword, newPassword, confirmPassword);
5656

5757
alert({
5858
alertType: 'success',
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
type SignOutFn = () => Promise<void>;
2+
3+
interface AccountLogoutDeps {
4+
signOut: SignOutFn;
5+
redirectToLogin: () => void;
6+
}
7+
8+
/**
9+
* Core (open-source) logout handler: sign out and redirect to /login.
10+
* Proprietary/desktop builds override this file via path resolution.
11+
*/
12+
export function useAccountLogout() {
13+
return async ({ signOut, redirectToLogin }: AccountLogoutDeps): Promise<void> => {
14+
try {
15+
await signOut();
16+
} finally {
17+
redirectToLogin();
18+
}
19+
};
20+
}

0 commit comments

Comments
 (0)