Skip to content

Commit 59bbecd

Browse files
redirect to signup page if no workspace found on login
1 parent a4ccd60 commit 59bbecd

File tree

3 files changed

+29
-10
lines changed

3 files changed

+29
-10
lines changed

client/packages/lowcoder/src/pages/userAuth/formLoginSteps.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
LoginCardTitle,
77
StyledRouteLink,
88
} from "pages/userAuth/authComponents";
9-
import React, { useContext, useMemo, useState } from "react";
9+
import React, { useContext, useState } from "react";
1010
import styled from "styled-components";
1111
import UserApi from "api/userApi";
1212
import { useRedirectUrl } from "util/hooks";
@@ -27,6 +27,7 @@ import { default as Button } from "antd/es/button";
2727
import LeftOutlined from "@ant-design/icons/LeftOutlined";
2828
import { fetchConfigAction } from "@lowcoder-ee/redux/reduxActions/configActions";
2929
import { useDispatch } from "react-redux";
30+
import history from "util/history";
3031

3132
const StyledCard = styled.div<{$selected: boolean}>`
3233
display: flex;
@@ -86,13 +87,16 @@ const StepBackButton = (props : {
8687
)
8788
export default function FormLoginSteps() {
8889
const dispatch = useDispatch();
89-
const [account, setAccount] = useState("");
90+
const location = useLocation();
91+
const [account, setAccount] = useState(() => {
92+
const { email } = (location.state || {}) as any;
93+
return email ?? '';
94+
});
9095
const [password, setPassword] = useState("");
9196
const redirectUrl = useRedirectUrl();
9297
const { systemConfig, inviteInfo, fetchUserAfterAuthSuccess } = useContext(AuthContext);
9398
const invitationId = inviteInfo?.invitationId;
9499
const authId = systemConfig?.form.id;
95-
const location = useLocation();
96100
const [orgLoading, setOrgLoading] = useState(false);
97101
const [orgList, setOrgList] = useState<OrgItem[]>([]);
98102
const [currentStep, setCurrentStep] = useState<CurrentStepEnum>(CurrentStepEnum.EMAIL);
@@ -121,9 +125,13 @@ export default function FormLoginSteps() {
121125
if (validateResponse(resp)) {
122126
setOrgList(resp.data.data);
123127
if (!resp.data.data.length) {
124-
throw new Error('Error: no workspaces found');
128+
history.push(
129+
AUTH_REGISTER_URL,
130+
{...location.state || {}, email: account},
131+
)
132+
return;
125133
}
126-
else if (resp.data.data.length === 1) {
134+
if (resp.data.data.length === 1) {
127135
setOrganizationId(resp.data.data[0].orgId);
128136
setCurrentStep(CurrentStepEnum.AUTH_PROVIDERS);
129137
return;

client/packages/lowcoder/src/pages/userAuth/register.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useContext, useState, useMemo } from "react";
1+
import React, { useContext, useState, useMemo, useEffect } from "react";
22
import {
33
AuthContainer,
44
ConfirmButton,
@@ -37,11 +37,14 @@ const RegisterContent = styled(FormWrapperMobile)`
3737
`;
3838

3939
function UserRegister() {
40+
const location = useLocation();
4041
const [submitBtnDisable, setSubmitBtnDisable] = useState(false);
41-
const [account, setAccount] = useState("");
42+
const [account, setAccount] = useState(() => {
43+
const { email } = (location.state || {}) as any;
44+
return email ?? '';
45+
});
4246
const [password, setPassword] = useState("");
4347
const redirectUrl = useRedirectUrl();
44-
const location = useLocation();
4548
const { systemConfig, inviteInfo, fetchUserAfterAuthSuccess } = useContext(AuthContext);
4649
const invitationId = inviteInfo?.invitationId;
4750

@@ -81,10 +84,10 @@ function UserRegister() {
8184
type="large"
8285
>
8386
<RegisterContent>
84-
{/* <LoginCardTitle>{trans("userAuth.registerByEmail")}</LoginCardTitle> */}
8587
<StyledFormInput
8688
className="form-input"
8789
label={trans("userAuth.email")}
90+
defaultValue={account}
8891
onChange={(value, valid) => setAccount(valid ? value : "")}
8992
placeholder={trans("userAuth.inputEmail")}
9093
checkRule={{

client/packages/lowcoder/src/pages/userAuth/thirdParty/thirdPartyAuth.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { WhiteLoading } from "lowcoder-design";
77
import history from "util/history";
88
import { LoginLogoStyle, LoginLabelStyle, StyledLoginButton } from "pages/userAuth/authComponents";
99
import { useSelector } from "react-redux";
10-
import { selectSystemConfig } from "redux/selectors/configSelectors";
10+
import { getSystemConfigFetching, selectSystemConfig } from "redux/selectors/configSelectors";
1111
import React from "react";
1212
import { messageInstance } from "lowcoder-design/src/components/GlobalInstances";
1313
import styled from "styled-components";
@@ -17,6 +17,8 @@ import { default as Divider } from "antd/es/divider";
1717
import { default as Typography } from "antd/es/typography";
1818
import { useRedirectUrl } from "util/hooks";
1919
import { MultiIconDisplay } from "../../../comps/comps/multiIconDisplay";
20+
import Spin from "antd/es/spin";
21+
import { LoadingOutlined } from "@ant-design/icons";
2022

2123
const { Text } = Typography;
2224

@@ -107,7 +109,13 @@ export function ThirdPartyAuth(props: {
107109
authGoal: ThirdPartyAuthGoal;
108110
labelFormatter?: (name: string) => string;
109111
}) {
112+
const systemConfigFetching = useSelector(getSystemConfigFetching);
110113
const systemConfig = useSelector(selectSystemConfig);
114+
115+
if (systemConfigFetching) {
116+
return <Spin indicator={<LoadingOutlined style={{ fontSize: 15, marginTop: '16px' }} spin />} />;
117+
}
118+
111119
if (!systemConfig) {
112120
return null;
113121
}

0 commit comments

Comments
 (0)