mirror of
https://github.com/PlayEdu/frontend.git
synced 2025-06-06 15:34:10 +08:00
commit
0029e81356
@ -10,3 +10,11 @@ export function login(email: string, password: string) {
|
||||
export function logout() {
|
||||
return client.post("/api/v1/auth/logout", {});
|
||||
}
|
||||
|
||||
export function loginLdap(email: string, password: string) {
|
||||
return client.post("/api/v1/auth/login/ldap", {
|
||||
username: email,
|
||||
password: password,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ export const InitPage = (props: Props) => {
|
||||
if (props.configData) {
|
||||
let config: SystemConfigStoreInterface = {
|
||||
//系统配置
|
||||
"ldap-enabled": props.configData["ldap-enabled"],
|
||||
systemApiUrl: props.configData["system-api-url"],
|
||||
systemH5Url: props.configData["system-h5-url"],
|
||||
systemLogo: props.configData["system-logo"],
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { Input, Button, message } from "antd";
|
||||
import React, { useState, useEffect } from "react";
|
||||
import React, { useState } from "react";
|
||||
import styles from "./index.module.scss";
|
||||
import banner from "../../assets/images/login/banner.png";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { loginAction } from "../../store/user/loginUserSlice";
|
||||
import { login, user } from "../../api/index";
|
||||
@ -15,10 +15,11 @@ const LoginPage: React.FC = () => {
|
||||
const [loading, setLoading] = useState<boolean>(false);
|
||||
const [email, setEmail] = useState<string>("");
|
||||
const [password, setPassword] = useState<string>("");
|
||||
const systemConfig = useSelector((state: any) => state.systemConfig.value);
|
||||
|
||||
const loginSubmit = (e: any) => {
|
||||
if (!email) {
|
||||
message.error("请输入学员邮箱账号");
|
||||
message.error("请输入邮箱或uid");
|
||||
return;
|
||||
}
|
||||
if (!password) {
|
||||
@ -42,16 +43,29 @@ const LoginPage: React.FC = () => {
|
||||
return;
|
||||
}
|
||||
setLoading(true);
|
||||
login
|
||||
.login(email, password)
|
||||
.then((res: any) => {
|
||||
const token = res.data.token;
|
||||
setToken(token);
|
||||
getUser();
|
||||
})
|
||||
.catch((e) => {
|
||||
setLoading(false);
|
||||
});
|
||||
if (systemConfig["ldap-enabled"] === "1") {
|
||||
login
|
||||
.loginLdap(email, password)
|
||||
.then((res: any) => {
|
||||
const token = res.data.token;
|
||||
setToken(token);
|
||||
getUser();
|
||||
})
|
||||
.catch((e) => {
|
||||
setLoading(false);
|
||||
});
|
||||
} else {
|
||||
login
|
||||
.login(email, password)
|
||||
.then((res: any) => {
|
||||
const token = res.data.token;
|
||||
setToken(token);
|
||||
getUser();
|
||||
})
|
||||
.catch((e) => {
|
||||
setLoading(false);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const getUser = () => {
|
||||
@ -79,7 +93,7 @@ const LoginPage: React.FC = () => {
|
||||
setEmail(e.target.value);
|
||||
}}
|
||||
style={{ width: 400, height: 54 }}
|
||||
placeholder="请输入学员邮箱账号"
|
||||
placeholder={"请输入邮箱或uid"}
|
||||
onKeyUp={(e) => keyUp(e)}
|
||||
/>
|
||||
</div>
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { createSlice } from "@reduxjs/toolkit";
|
||||
|
||||
type SystemConfigStoreInterface = {
|
||||
"ldap-enabled": string;
|
||||
systemApiUrl: string;
|
||||
systemPcUrl: string;
|
||||
systemH5Url: string;
|
||||
@ -16,6 +17,7 @@ type SystemConfigStoreInterface = {
|
||||
};
|
||||
|
||||
let defaultValue: SystemConfigStoreInterface = {
|
||||
"ldap-enabled": "",
|
||||
systemApiUrl: "",
|
||||
systemPcUrl: "",
|
||||
systemH5Url: "",
|
||||
|
Loading…
x
Reference in New Issue
Block a user