Skip to content

Commit b968f8b

Browse files
added admin login page
1 parent e05025e commit b968f8b

File tree

7 files changed

+34
-55
lines changed

7 files changed

+34
-55
lines changed

client/packages/lowcoder/src/app.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
ADMIN_APP_URL,
2929
ORG_AUTH_FORGOT_PASSWORD_URL,
3030
ORG_AUTH_RESET_PASSWORD_URL,
31+
ADMIN_AUTH_URL,
3132
} from "constants/routesURL";
3233
import React from "react";
3334
import { createRoot } from "react-dom/client";
@@ -337,6 +338,7 @@ class AppIndex extends React.Component<AppIndexProps, any> {
337338
// component={ApplicationListPage}
338339
component={LazyApplicationHome}
339340
/>
341+
<LazyRoute exact path={ADMIN_AUTH_URL} component={LazyUserAuthComp} />
340342
<LazyRoute path={USER_AUTH_URL} component={LazyUserAuthComp} />
341343
<LazyRoute
342344
path={ORG_AUTH_LOGIN_URL}

client/packages/lowcoder/src/constants/routesURL.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { UserGuideLocationState } from "pages/tutorials/tutorialsConstant";
44
import { DatasourceType } from "@lowcoder-ee/constants/queryConstants";
55

66
export const BASE_URL = "/";
7+
export const ADMIN_AUTH_URL = "/admin/login";
78
export const USER_AUTH_URL = "/user/auth";
89
export const USER_PROFILE_URL = "/user/profile";
910
export const NEWS_URL = "/news";
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,15 @@
11
import { FormInput, PasswordInput } from "lowcoder-design";
22
import {
3-
AuthBottomView,
43
ConfirmButton,
54
FormWrapperMobile,
6-
LoginCardTitle,
7-
StyledRouteLink,
85
} from "pages/userAuth/authComponents";
96
import React, { useContext, useState } from "react";
107
import styled from "styled-components";
118
import UserApi from "api/userApi";
12-
import { useRedirectUrl } from "util/hooks";
139
import { checkEmailValid, checkPhoneValid } from "util/stringUtils";
1410
import { UserConnectionSource } from "@lowcoder-ee/constants/userConstants";
1511
import { trans } from "i18n";
1612
import { AuthContext, useAuthSubmit } from "pages/userAuth/authUtils";
17-
import { ThirdPartyAuth } from "pages/userAuth/thirdParty/thirdPartyAuth";
18-
import { AUTH_FORGOT_PASSWORD_URL, AUTH_REGISTER_URL, ORG_AUTH_FORGOT_PASSWORD_URL, ORG_AUTH_REGISTER_URL } from "constants/routesURL";
19-
import { Link, useLocation, useParams } from "react-router-dom";
20-
import { Divider } from "antd";
21-
import Flex from "antd/es/flex";
2213

2314
export const AccountLoginWrapper = styled(FormWrapperMobile)`
2415
position: relative;
@@ -38,26 +29,19 @@ type FormLoginProps = {
3829
export default function FormLogin(props: FormLoginProps) {
3930
const [account, setAccount] = useState("");
4031
const [password, setPassword] = useState("");
41-
const redirectUrl = useRedirectUrl();
42-
const { systemConfig, inviteInfo, fetchUserAfterAuthSuccess } = useContext(AuthContext);
43-
const invitationId = inviteInfo?.invitationId;
44-
const authId = systemConfig?.form.id;
45-
const location = useLocation();
46-
const orgId = useParams<any>().orgId;
32+
const { fetchUserAfterAuthSuccess } = useContext(AuthContext);
4733

4834
const { onSubmit, loading } = useAuthSubmit(
4935
() =>
5036
UserApi.formLogin({
5137
register: false,
5238
loginId: account,
5339
password: password,
54-
invitationId: invitationId,
5540
source: UserConnectionSource.email,
5641
orgId: props.organizationId,
57-
authId,
5842
}),
5943
false,
60-
redirectUrl,
44+
null,
6145
fetchUserAfterAuthSuccess,
6246
);
6347

@@ -79,38 +63,10 @@ export default function FormLogin(props: FormLoginProps) {
7963
onChange={(value) => setPassword(value)}
8064
valueCheck={() => [true, ""]}
8165
/>
82-
<Flex justify="end" style={{margin: '10px 0'}}>
83-
<Link to={{
84-
pathname: orgId
85-
? ORG_AUTH_FORGOT_PASSWORD_URL.replace(':orgId', orgId)
86-
: AUTH_FORGOT_PASSWORD_URL,
87-
state: location.state
88-
}}
89-
>
90-
{`${trans("userAuth.forgotPassword")}?`}
91-
</Link>
92-
</Flex>
93-
<ConfirmButton loading={loading} disabled={!account || !password} onClick={onSubmit}>
66+
<ConfirmButton style={{marginTop: '32px'}} loading={loading} disabled={!account || !password} onClick={onSubmit}>
9467
{trans("userAuth.login")}
9568
</ConfirmButton>
96-
{props.organizationId && (
97-
<ThirdPartyAuth
98-
invitationId={invitationId}
99-
invitedOrganizationId={props.organizationId}
100-
authGoal="login"
101-
/>
102-
)}
10369
</AccountLoginWrapper>
104-
<Divider/>
105-
<AuthBottomView>
106-
<StyledRouteLink to={{
107-
pathname: orgId
108-
? ORG_AUTH_REGISTER_URL.replace(':orgId', orgId)
109-
: AUTH_REGISTER_URL,
110-
state: location.state
111-
}}>{trans("userAuth.register")}
112-
</StyledRouteLink>
113-
</AuthBottomView>
11470
</>
11571
);
11672
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ import { Divider } from "antd";
2121
import Flex from "antd/es/flex";
2222
import { validateResponse } from "@lowcoder-ee/api/apiUtils";
2323
import OrgApi from "@lowcoder-ee/api/orgApi";
24-
import Card from "antd/es/card/Card";
25-
import { AccountLoginWrapper } from "./formLogin";
24+
import { AccountLoginWrapper } from "./formLoginAdmin";
2625
import { default as Button } from "antd/es/button";
2726
import LeftOutlined from "@ant-design/icons/LeftOutlined";
2827
import { fetchConfigAction } from "@lowcoder-ee/redux/reduxActions/configActions";

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AUTH_LOGIN_URL, USER_AUTH_URL } from "constants/routesURL";
1+
import { ADMIN_AUTH_URL, AUTH_LOGIN_URL, USER_AUTH_URL } from "constants/routesURL";
22
import { Redirect, Route, Switch, useLocation, useParams } from "react-router-dom";
33
import React, { useEffect, useMemo } from "react";
44
import { useSelector, useDispatch } from "react-redux";
@@ -9,6 +9,7 @@ import { AuthLocationState } from "constants/authConstants";
99
import { ProductLoading } from "components/ProductLoading";
1010
import { fetchConfigAction } from "redux/reduxActions/configActions";
1111
import { fetchUserAction } from "redux/reduxActions/userActions";
12+
import LoginAdmin from "./loginAdmin";
1213
import _ from "lodash";
1314

1415
export default function UserAuth() {
@@ -51,6 +52,7 @@ export default function UserAuth() {
5152
>
5253
<Switch location={location}>
5354
<Redirect exact from={USER_AUTH_URL} to={AUTH_LOGIN_URL} />
55+
<Route exact path={ADMIN_AUTH_URL} component={LoginAdmin} />
5456
{AuthRoutes.map((route) => (
5557
<Route key={route.path} path={route.path} component={route.component} />
5658
))}

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { AuthSearchParams } from "constants/authConstants";
33
import { CommonTextLabel } from "components/Label";
44
import { trans } from "i18n";
55
import { ThirdPartyAuth } from "pages/userAuth/thirdParty/thirdPartyAuth";
6-
import FormLogin from "@lowcoder-ee/pages/userAuth/formLogin";
6+
import FormLogin from "@lowcoder-ee/pages/userAuth/formLoginAdmin";
77
import { AuthContainer } from "pages/userAuth/authComponents";
88
import React, { useContext, useMemo } from "react";
99
import { AuthContext, getLoginTitle } from "pages/userAuth/authUtils";
@@ -145,10 +145,6 @@ function Login() {
145145
subHeading={loginSubHeading}
146146
>
147147
<FormLoginSteps organizationId={organizationId} />
148-
{/* { Boolean(organizationId)
149-
? <FormLogin organizationId={organizationId} />
150-
: <FormLoginSteps />
151-
} */}
152148
</AuthContainer>
153149
</>
154150
);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { trans } from "i18n";
2+
import FormLogin from "@lowcoder-ee/pages/userAuth/formLoginAdmin";
3+
import { AuthContainer } from "pages/userAuth/authComponents";
4+
import { requiresUnAuth } from "pages/userAuth/authHOC";
5+
6+
// this is the classic Sign In for super admin
7+
function LoginAdmin() {
8+
const loginHeading = trans("userAuth.userLogin");
9+
const loginSubHeading = trans("userAuth.poweredByLowcoder");
10+
11+
return (
12+
<>
13+
<AuthContainer
14+
heading={loginHeading}
15+
subHeading={loginSubHeading}
16+
>
17+
<FormLogin />
18+
</AuthContainer>
19+
</>
20+
);
21+
}
22+
23+
export default requiresUnAuth(LoginAdmin);

0 commit comments

Comments
 (0)