Skip to content

Commit

Permalink
chore: check currentUser and redirect to index if logged (#4021)
Browse files Browse the repository at this point in the history
* If to check currentUser and redirect to index if logged

* Moved check into useEffect
  • Loading branch information
monkeymatt0 authored Oct 19, 2024
1 parent e5cb203 commit 1909894
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions web/src/pages/SignIn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import LocaleSelect from "@/components/LocaleSelect";
import PasswordSignInForm from "@/components/PasswordSignInForm";
import { identityProviderServiceClient } from "@/grpcweb";
import { absolutifyLink } from "@/helpers/utils";
import useCurrentUser from "@/hooks/useCurrentUser";
import { useCommonContext } from "@/layouts/CommonContextProvider";
import { Routes } from "@/router";
import { extractIdentityProviderIdFromName, useWorkspaceSettingStore } from "@/store/v1";
import { IdentityProvider, IdentityProvider_Type } from "@/types/proto/api/v1/idp_service";
import { WorkspaceGeneralSetting } from "@/types/proto/api/v1/workspace_setting_service";
Expand All @@ -16,13 +18,17 @@ import { useTranslate } from "@/utils/i18n";

const SignIn = () => {
const t = useTranslate();
const currentUser = useCurrentUser();
const commonContext = useCommonContext();
const workspaceSettingStore = useWorkspaceSettingStore();
const [identityProviderList, setIdentityProviderList] = useState<IdentityProvider[]>([]);
const workspaceGeneralSetting =
workspaceSettingStore.getWorkspaceSettingByKey(WorkspaceSettingKey.GENERAL).generalSetting || WorkspaceGeneralSetting.fromPartial({});

useEffect(() => {
if (currentUser) {
window.location.href = Routes.ROOT;
}
const fetchIdentityProviderList = async () => {
const { identityProviders } = await identityProviderServiceClient.listIdentityProviders({});
setIdentityProviderList(identityProviders);
Expand Down

0 comments on commit 1909894

Please sign in to comment.