mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 18:54:03 +08:00
Improve signup page.
This commit is contained in:
parent
ef1995de4f
commit
ee8f2a6046
@ -345,6 +345,7 @@ class App extends Component {
|
|||||||
</Header>
|
</Header>
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route exact path="/signup" render={(props) => this.renderHomeIfLoggedIn(<SignupPage {...props} />)}/>
|
<Route exact path="/signup" render={(props) => this.renderHomeIfLoggedIn(<SignupPage {...props} />)}/>
|
||||||
|
<Route exact path="/signup/:applicationName" render={(props) => this.renderHomeIfLoggedIn(<SignupPage {...props} />)}/>
|
||||||
<Route exact path="/result" render={(props) => this.renderHomeIfLoggedIn(<ResultPage {...props} />)}/>
|
<Route exact path="/result" render={(props) => this.renderHomeIfLoggedIn(<ResultPage {...props} />)}/>
|
||||||
<Route exact path="/login" render={(props) => this.renderHomeIfLoggedIn(<SelfLoginPage {...props} />)}/>
|
<Route exact path="/login" render={(props) => this.renderHomeIfLoggedIn(<SelfLoginPage {...props} />)}/>
|
||||||
<Route exact path="/callback" component={AuthCallback}/>
|
<Route exact path="/callback" component={AuthCallback}/>
|
||||||
|
@ -179,3 +179,21 @@ export function getProviderLogo(provider) {
|
|||||||
<img width={30} height={30} src={url} alt={idp} />
|
<img width={30} height={30} src={url} alt={idp} />
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function renderLogo(application) {
|
||||||
|
if (application === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (application.homepageUrl !== "") {
|
||||||
|
return (
|
||||||
|
<a target="_blank" rel="noreferrer" href={application.homepageUrl}>
|
||||||
|
<img width={250} src={application.logo} alt={application.displayName} style={{marginBottom: '30px'}}/>
|
||||||
|
</a>
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
<img width={250} src={application.logo} alt={application.displayName} style={{marginBottom: '30px'}}/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
export let authConfig = {
|
export let authConfig = {
|
||||||
serverUrl: "http://example.com", // your Casdoor URL, like the official one: https://door.casbin.com
|
serverUrl: "http://example.com", // your Casdoor URL, like the official one: https://door.casbin.com
|
||||||
appName: "app-example", // your Casdoor application name, like: "app-built-in"
|
appName: "app-built-in", // your Casdoor application name, like: "app-built-in"
|
||||||
organizationName: "org-example", // your Casdoor organization name, like: "built-in"
|
organizationName: "built-in", // your Casdoor organization name, like: "built-in"
|
||||||
}
|
}
|
||||||
|
|
||||||
export function initAuthWithConfig(config) {
|
export function initAuthWithConfig(config) {
|
||||||
|
@ -262,20 +262,6 @@ class LoginPage extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
renderLogo(application) {
|
|
||||||
if (application.homepageUrl !== "") {
|
|
||||||
return (
|
|
||||||
<a target="_blank" rel="noreferrer" href={application.homepageUrl}>
|
|
||||||
<img width={250} src={application.logo} alt={application.displayName} style={{marginBottom: '30px'}}/>
|
|
||||||
</a>
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
return (
|
|
||||||
<img width={250} src={application.logo} alt={application.displayName} style={{marginBottom: '30px'}}/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const application = this.getApplicationObj();
|
const application = this.getApplicationObj();
|
||||||
if (application === null) {
|
if (application === null) {
|
||||||
@ -287,7 +273,7 @@ class LoginPage extends React.Component {
|
|||||||
<Col span={24} style={{display: "flex", justifyContent: "center"}}>
|
<Col span={24} style={{display: "flex", justifyContent: "center"}}>
|
||||||
<div style={{marginTop: "80px", textAlign: "center"}}>
|
<div style={{marginTop: "80px", textAlign: "center"}}>
|
||||||
{
|
{
|
||||||
this.renderLogo(application)
|
Setting.renderLogo(application)
|
||||||
}
|
}
|
||||||
{/*{*/}
|
{/*{*/}
|
||||||
{/* this.state.clientId !== null ? "Redirect" : null*/}
|
{/* this.state.clientId !== null ? "Redirect" : null*/}
|
||||||
|
@ -18,6 +18,9 @@ import {Form, Input, Select, Checkbox, Button, Row, Col} from 'antd';
|
|||||||
import * as Setting from "../Setting";
|
import * as Setting from "../Setting";
|
||||||
import * as AuthBackend from "./AuthBackend";
|
import * as AuthBackend from "./AuthBackend";
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
|
import * as Util from "./Util";
|
||||||
|
import {authConfig} from "./Auth";
|
||||||
|
import * as ApplicationBackend from "../backend/ApplicationBackend";
|
||||||
|
|
||||||
const { Option } = Select;
|
const { Option } = Select;
|
||||||
|
|
||||||
@ -27,7 +30,7 @@ const formItemLayout = {
|
|||||||
span: 24,
|
span: 24,
|
||||||
},
|
},
|
||||||
sm: {
|
sm: {
|
||||||
span: 8,
|
span: 6,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
wrapperCol: {
|
wrapperCol: {
|
||||||
@ -35,7 +38,7 @@ const formItemLayout = {
|
|||||||
span: 24,
|
span: 24,
|
||||||
},
|
},
|
||||||
sm: {
|
sm: {
|
||||||
span: 16,
|
span: 18,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -58,11 +61,34 @@ class SignupPage extends React.Component {
|
|||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
classes: props,
|
classes: props,
|
||||||
|
applicationName: props.match.params.applicationName !== undefined ? props.match.params.applicationName : authConfig.appName,
|
||||||
|
application: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.form = React.createRef();
|
this.form = React.createRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UNSAFE_componentWillMount() {
|
||||||
|
if (this.state.applicationName !== undefined) {
|
||||||
|
this.getApplication();
|
||||||
|
} else {
|
||||||
|
Util.showMessage("error", `Unknown application name: ${this.state.applicationName}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getApplication() {
|
||||||
|
if (this.state.applicationName === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ApplicationBackend.getApplication("admin", this.state.applicationName)
|
||||||
|
.then((application) => {
|
||||||
|
this.setState({
|
||||||
|
application: application,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
onFinish(values) {
|
onFinish(values) {
|
||||||
AuthBackend.signup(values)
|
AuthBackend.signup(values)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
@ -78,7 +104,7 @@ class SignupPage extends React.Component {
|
|||||||
this.form.current.scrollToField(errorFields[0].name);
|
this.form.current.scrollToField(errorFields[0].name);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderForm() {
|
renderForm(application) {
|
||||||
const prefixSelector = (
|
const prefixSelector = (
|
||||||
<Form.Item name="prefix" noStyle>
|
<Form.Item name="prefix" noStyle>
|
||||||
<Select
|
<Select
|
||||||
@ -100,6 +126,7 @@ class SignupPage extends React.Component {
|
|||||||
onFinish={(values) => this.onFinish(values)}
|
onFinish={(values) => this.onFinish(values)}
|
||||||
onFinishFailed={(errorInfo) => this.onFinishFailed(errorInfo.values, errorInfo.errorFields, errorInfo.outOfDate)}
|
onFinishFailed={(errorInfo) => this.onFinishFailed(errorInfo.values, errorInfo.errorFields, errorInfo.outOfDate)}
|
||||||
initialValues={{
|
initialValues={{
|
||||||
|
application: application.name,
|
||||||
prefix: '86',
|
prefix: '86',
|
||||||
}}
|
}}
|
||||||
style={{width: !Setting.isMobile() ? "400px" : "250px"}}
|
style={{width: !Setting.isMobile() ? "400px" : "250px"}}
|
||||||
@ -235,14 +262,24 @@ class SignupPage extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const application = this.state.application;
|
||||||
|
if (application === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
|
||||||
<Row>
|
<Row>
|
||||||
<Col span={24} style={{display: "flex", justifyContent: "center"}} >
|
<Col span={24} style={{display: "flex", justifyContent: "center"}} >
|
||||||
{
|
<div style={{marginTop: "10px", textAlign: "center"}}>
|
||||||
this.renderForm()
|
{
|
||||||
}
|
Setting.renderLogo(application)
|
||||||
|
}
|
||||||
|
{
|
||||||
|
this.renderForm(application)
|
||||||
|
}
|
||||||
|
</div>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user