temp
This commit is contained in:
@@ -35,36 +35,27 @@ const Login = (props: LoginProps) => {
|
||||
}
|
||||
}, [history, auth]);
|
||||
|
||||
const handleSubmit = (values: any) => {
|
||||
if (checkUser(values)) {
|
||||
const handleSubmit = async (values: any) => {
|
||||
console.log(await checkUser(values));
|
||||
if (await checkUser(values)) {
|
||||
setAlita({ funcName: values.userName, stateName: 'auth' });
|
||||
}
|
||||
};
|
||||
const checkUser = (values: any) => {
|
||||
// const users = [
|
||||
// ['admin', 'admin'],
|
||||
// ['guest', 'guest'],
|
||||
// ];
|
||||
// return users.some((user) => user[0] === values.userName && user[1] === values.password);
|
||||
let success = trailwayLogin({ username: values.userName, password: values.password }).then(
|
||||
(res) => {
|
||||
console.log(res);
|
||||
return res.data.success === true;
|
||||
}
|
||||
);
|
||||
console.log(success);
|
||||
const checkUser = async (values: any) => {
|
||||
let success = await trailwayLogin({
|
||||
username: values.userName,
|
||||
password: values.password,
|
||||
}).then((res) => {
|
||||
return res.data.success;
|
||||
});
|
||||
return success;
|
||||
};
|
||||
const gitHub = () => {
|
||||
window.location.href =
|
||||
'https://github.com/login/oauth/authorize?client_id=792cdcd244e98dcd2dee&redirect_uri=http://localhost:3006/&scope=user&state=reactAdmin';
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="login">
|
||||
<div className="login-form">
|
||||
<div className="login-logo">
|
||||
<span>React Admin</span>
|
||||
<span>地铁可视化</span>
|
||||
<PwaInstaller />
|
||||
</div>
|
||||
<Form onFinish={handleSubmit} style={{ maxWidth: '300px' }}>
|
||||
@@ -72,22 +63,16 @@ const Login = (props: LoginProps) => {
|
||||
name="userName"
|
||||
rules={[{ required: true, message: '请输入用户名!' }]}
|
||||
>
|
||||
<Input
|
||||
prefix={<UserOutlined size={13} />}
|
||||
placeholder="管理员输入admin, 游客输入guest"
|
||||
/>
|
||||
<Input prefix={<UserOutlined size={13} />} placeholder="Username" />
|
||||
</FormItem>
|
||||
<FormItem name="password" rules={[{ required: true, message: '请输入密码!' }]}>
|
||||
<Input
|
||||
prefix={<LockOutlined size={13} />}
|
||||
type="password"
|
||||
placeholder="管理员输入admin, 游客输入guest"
|
||||
placeholder="Password"
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem>
|
||||
<span className="login-form-forgot" style={{ float: 'right' }}>
|
||||
忘记密码
|
||||
</span>
|
||||
<Button
|
||||
type="primary"
|
||||
htmlType="submit"
|
||||
@@ -96,13 +81,6 @@ const Login = (props: LoginProps) => {
|
||||
>
|
||||
登录
|
||||
</Button>
|
||||
<p style={{ display: 'flex', justifyContent: 'space-between' }}>
|
||||
<span>或 现在就去注册!</span>
|
||||
<span onClick={gitHub}>
|
||||
<GithubOutlined />
|
||||
(第三方登录)
|
||||
</span>
|
||||
</p>
|
||||
</FormItem>
|
||||
</Form>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user