Skip to content

Commit e05025e

Browse files
show new auth flow when user is invited or joins by org url
1 parent 22e8f2d commit e05025e

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

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

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,12 @@ const StepBackButton = (props : {
8585
Back
8686
</Button>
8787
)
88-
export default function FormLoginSteps() {
88+
89+
type FormLoginProps = {
90+
organizationId?: string;
91+
}
92+
93+
export default function FormLoginSteps(props: FormLoginProps) {
8994
const dispatch = useDispatch();
9095
const location = useLocation();
9196
const [account, setAccount] = useState(() => {
@@ -100,7 +105,8 @@ export default function FormLoginSteps() {
100105
const [orgLoading, setOrgLoading] = useState(false);
101106
const [orgList, setOrgList] = useState<OrgItem[]>([]);
102107
const [currentStep, setCurrentStep] = useState<CurrentStepEnum>(CurrentStepEnum.EMAIL);
103-
const [organizationId, setOrganizationId] = useState<string>();
108+
const [organizationId, setOrganizationId] = useState<string|undefined>(props.organizationId);
109+
const [skipWorkspaceStep, setSkipWorkspaceStep] = useState<boolean>(false);
104110

105111
const { onSubmit, loading } = useAuthSubmit(
106112
() =>
@@ -119,6 +125,15 @@ export default function FormLoginSteps() {
119125
);
120126

121127
const fetchOrgsByEmail = () => {
128+
// if user is invited or using org's login url then avoid fetching workspaces
129+
// and skip workspace selection step
130+
if (organizationId) {
131+
setSkipWorkspaceStep(true);
132+
dispatch(fetchConfigAction(organizationId));
133+
setCurrentStep(CurrentStepEnum.AUTH_PROVIDERS);
134+
return;
135+
}
136+
122137
setOrgLoading(true);
123138
OrgApi.fetchOrgsByEmail(account)
124139
.then((resp) => {
@@ -209,7 +224,10 @@ export default function FormLoginSteps() {
209224
return (
210225
<>
211226
<AccountLoginWrapper>
212-
<StepBackButton onClick={() => setCurrentStep(CurrentStepEnum.WORKSPACES)} />
227+
<StepBackButton onClick={() => {
228+
if (skipWorkspaceStep) return setCurrentStep(CurrentStepEnum.EMAIL);
229+
setCurrentStep(CurrentStepEnum.WORKSPACES)
230+
}} />
213231
<StepHeader title={trans("userAuth.enterPassword")} />
214232
<PasswordInput
215233
className="form-input password-input"

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,11 @@ function Login() {
144144
heading={loginHeading}
145145
subHeading={loginSubHeading}
146146
>
147-
{ Boolean(organizationId)
147+
<FormLoginSteps organizationId={organizationId} />
148+
{/* { Boolean(organizationId)
148149
? <FormLogin organizationId={organizationId} />
149150
: <FormLoginSteps />
150-
}
151+
} */}
151152
</AuthContainer>
152153
</>
153154
);

0 commit comments

Comments
 (0)