Skip to content

Commit

Permalink
chore: improve check for alby automatic auth on setup finish
Browse files Browse the repository at this point in the history
  • Loading branch information
rolznz committed Sep 12, 2024
1 parent d5fa794 commit 9d8ffb3
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions frontend/src/screens/setup/SetupFinish.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ export function SetupFinish() {
}, [loading]);

useEffect(() => {
if (!info) {
return;
}
// ensure setup call is only called once
if (hasFetchedRef.current) {
return;
Expand All @@ -82,14 +85,19 @@ export function SetupFinish() {

(async () => {
setLoading(true);
const succeeded = await finishSetup(nodeInfo, unlockPassword, toast);
const succeeded = await finishSetup(
nodeInfo,
unlockPassword,
toast,
info.oauthRedirect
);
// only setup call is successful as start is async
if (!succeeded) {
setLoading(false);
setConnectionError(true);
}
})();
}, [nodeInfo, navigate, unlockPassword, toast]);
}, [nodeInfo, navigate, unlockPassword, toast, info]);

if (connectionError) {
return (
Expand Down Expand Up @@ -126,11 +134,12 @@ export function SetupFinish() {
const finishSetup = async (
nodeInfo: SetupNodeInfo,
unlockPassword: string,
toast: ToastSignature
toast: ToastSignature,
autoAuth: boolean
): Promise<boolean> => {
try {
let redirectTo = "/alby/account";
if (window.location.origin === "https://my.albyhub.com") {
if (autoAuth) {
redirectTo = "/alby/auth";
}

Expand Down

0 comments on commit 9d8ffb3

Please sign in to comment.