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