diff --git a/src/client/web/src/components/__test__/state_mgr.test.tsx b/src/client/web/src/components/__test__/state_mgr.test.tsx index e3b39fe..28c1e0e 100644 --- a/src/client/web/src/components/__test__/state_mgr.test.tsx +++ b/src/client/web/src/components/__test__/state_mgr.test.tsx @@ -123,9 +123,7 @@ describe("State Manager", () => { expect(coreState.msg.pkg).toEqual(MsgPackage.get("en_US")); // ui - expect(coreState.ui.bg).toEqual( - settingsResps.getClientCfgMockResp.data.bg - ); + expect(coreState.ui.bg).toEqual(settingsResps.getClientCfgMockResp.data.bg); }); test("initUpdater for visitor in sharing mode", async () => { @@ -225,9 +223,7 @@ describe("State Manager", () => { expect(coreState.msg.pkg).toEqual(MsgPackage.get("en_US")); // ui - expect(coreState.ui.bg).toEqual( - settingsResps.getClientCfgMockResp.data.bg - ); + expect(coreState.ui.bg).toEqual(settingsResps.getClientCfgMockResp.data.bg); }); test("initUpdater for visitor", async () => { @@ -251,9 +247,9 @@ describe("State Manager", () => { ); usersCl.getCaptchaID = jest.fn().mockReturnValue( makePromise({ - status: 400, + status: 200, statusText: "", - data: { error: "empty captcha ID" }, + data: { id: "357124" }, }) ); @@ -292,7 +288,7 @@ describe("State Manager", () => { usedSpace: "0", }, authed: false, - captchaID: "", + captchaID: "357124", preferences: { bg: { url: "", @@ -319,10 +315,10 @@ describe("State Manager", () => { // ui expect(coreState.ui.bg).toEqual({ - url: "", - repeat: "", - position: "", - align: "", + align: "clientCfg_bg_align", + position: "clientCfg_bg_position", + repeat: "clientCfg_bg_repeat", + url: "clientCfg_bg_url", }); }); }); diff --git a/src/client/web/src/components/state_updater.ts b/src/client/web/src/components/state_updater.ts index 03d5b3e..dd0967d 100644 --- a/src/client/web/src/components/state_updater.ts +++ b/src/client/web/src/components/state_updater.ts @@ -520,6 +520,11 @@ export class Updater { }; initAuth = async (): Promise => { + const getCapStatus = await this.getCaptchaID(); + if (getCapStatus !== "") { + return getCapStatus; + } + const isAuthedStatus = await this.syncIsAuthed(); if (isAuthedStatus !== "") { return isAuthedStatus; @@ -530,11 +535,6 @@ export class Updater { return selfStatuses; } - const getCapStatus = await this.getCaptchaID(); - if (getCapStatus !== "") { - return getCapStatus; - } - return ""; }; @@ -600,7 +600,6 @@ export class Updater { spaceLimit: "0", }; this.props.login.authed = false; - this.props.login.captchaID = ""; this.props.login.preferences = { bg: { url: "", @@ -732,7 +731,7 @@ export class Updater { syncIsAuthed = async (): Promise => { const resp = await this.usersClient.isAuthed(); if (resp.status !== 200) { - this.props.login.authed = false; + this.resetUser(); return resp.status === 401 ? "" : errServer; } this.props.login.authed = true;