add tenant permission
parent
7e44a00d30
commit
9a52b3dd47
|
@ -42,3 +42,7 @@
|
||||||
.MuiFormControlLabel-label {
|
.MuiFormControlLabel-label {
|
||||||
font-size: 13px !important;
|
font-size: 13px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.MuiDialog-root {
|
||||||
|
background-color: white;
|
||||||
|
}
|
28
src/App.js
28
src/App.js
|
@ -1,6 +1,7 @@
|
||||||
import "./App.css";
|
import "./App.css";
|
||||||
import * as ProjectApi from "./apis/projectApi";
|
import * as ProjectApi from "./apis/projectApi";
|
||||||
import * as LoginApi from "./apis/loginApi";
|
import * as LoginApi from "./apis/loginApi";
|
||||||
|
import * as utils from "./utils";
|
||||||
import Pane from "./Components/pane";
|
import Pane from "./Components/pane";
|
||||||
import DeviceFrame from "./Components/deviceFrame";
|
import DeviceFrame from "./Components/deviceFrame";
|
||||||
import waterMarkPng from "./images/water-mark.png";
|
import waterMarkPng from "./images/water-mark.png";
|
||||||
|
@ -34,7 +35,7 @@ class App extends React.Component {
|
||||||
dataUrl: "",
|
dataUrl: "",
|
||||||
loading: false,
|
loading: false,
|
||||||
loginOpen: false,
|
loginOpen: false,
|
||||||
showLoginError: false,
|
loginErrorMessage: "",
|
||||||
loginForm: {
|
loginForm: {
|
||||||
account: "",
|
account: "",
|
||||||
password: "",
|
password: "",
|
||||||
|
@ -44,18 +45,23 @@ class App extends React.Component {
|
||||||
}
|
}
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const loginInfo = getLoginInfo();
|
const loginInfo = getLoginInfo();
|
||||||
if (loginInfo) {
|
var tenant = utils.getTenant();
|
||||||
|
if (loginInfo && loginInfo.permissionPages.includes(tenant)) {
|
||||||
this.fetchData();
|
this.fetchData();
|
||||||
this.refreshQrCode();
|
this.refreshQrCode();
|
||||||
} else {
|
} else {
|
||||||
this.setState({ loginOpen: true });
|
this.setState({ loginOpen: true });
|
||||||
|
loginInfo &&
|
||||||
|
this.setState({ loginErrorMessage: "无权限访问,请切换账号" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
login = async () => {
|
login = async () => {
|
||||||
var { account, password, keepLogin } = this.state.loginForm;
|
var { account, password, keepLogin } = this.state.loginForm;
|
||||||
var user = await LoginApi.UserLogin({ account, password });
|
var user = await LoginApi.UserLogin({ account, password });
|
||||||
if (user) {
|
var tenant = utils.getTenant();
|
||||||
|
|
||||||
|
if (user && user.permissionPages.includes(tenant)) {
|
||||||
this.setState({
|
this.setState({
|
||||||
loginOpen: false,
|
loginOpen: false,
|
||||||
});
|
});
|
||||||
|
@ -66,7 +72,9 @@ class App extends React.Component {
|
||||||
this.refreshQrCode();
|
this.refreshQrCode();
|
||||||
} else {
|
} else {
|
||||||
this.setState({
|
this.setState({
|
||||||
showLoginError: true,
|
loginErrorMessage: user
|
||||||
|
? `无权限访问${tenant},请切换账号`
|
||||||
|
: "账号或密码错误",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -205,9 +213,15 @@ class App extends React.Component {
|
||||||
/>
|
/>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
<DialogActions>
|
<DialogActions>
|
||||||
{this.state.showLoginError && (
|
{this.state.loginErrorMessage && (
|
||||||
<span style={{ color: "red", margin: "0 auto 0 10px" }}>
|
<span
|
||||||
账号或密码错误
|
style={{
|
||||||
|
color: "red",
|
||||||
|
fontSize: "12px",
|
||||||
|
margin: "0 auto 0 10px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{this.state.loginErrorMessage}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
<FormControlLabel
|
<FormControlLabel
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import queryString from 'query-string'
|
import queryString from "query-string";
|
||||||
|
|
||||||
export function getTenant() {
|
export function getTenant() {
|
||||||
const tenant = queryString.parseUrl(window.location.href)?.query?.tenant
|
const tenant = queryString.parseUrl(window.location.href)?.query?.tenant;
|
||||||
return tenant || "funplus"
|
return tenant?.toLowerCase() || "funplus";
|
||||||
}
|
}
|
Loading…
Reference in New Issue