mirror of
https://github.com/Unleash/unleash.git
synced 2025-05-17 01:17:29 +02:00
fix: password login should prefer login options
This commit is contained in:
parent
01d747e590
commit
400e8bdb26
@ -16,6 +16,11 @@ class EnterpriseAuthenticationComponent extends React.Component {
|
|||||||
this.state = {};
|
this.state = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onShowOptions = e => {
|
||||||
|
e.preventDefault();
|
||||||
|
this.setState({ showFields: true });
|
||||||
|
};
|
||||||
|
|
||||||
handleSubmit = async evt => {
|
handleSubmit = async evt => {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
const { username, password } = this.state;
|
const { username, password } = this.state;
|
||||||
@ -47,7 +52,7 @@ class EnterpriseAuthenticationComponent extends React.Component {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
renderLoginForm() {
|
||||||
const authDetails = this.props.authDetails;
|
const authDetails = this.props.authDetails;
|
||||||
const { username, usernameError, password, passwordError, error } = this.state;
|
const { username, usernameError, password, passwordError, error } = this.state;
|
||||||
return (
|
return (
|
||||||
@ -82,6 +87,35 @@ class EnterpriseAuthenticationComponent extends React.Component {
|
|||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
renderWithOptions(options) {
|
||||||
|
return (
|
||||||
|
<div style={{ textAlign: 'center' }}>
|
||||||
|
{options.map(o => (
|
||||||
|
<CardActions key={o.type}>
|
||||||
|
<Button raised accent href={o.path}>
|
||||||
|
{o.value}
|
||||||
|
</Button>
|
||||||
|
</CardActions>
|
||||||
|
))}
|
||||||
|
{this.state.showFields ? (
|
||||||
|
this.renderLoginForm()
|
||||||
|
) : (
|
||||||
|
<a href="" onClick={this.onShowOptions}>
|
||||||
|
Show more options
|
||||||
|
</a>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const { options = [] } = this.props.authDetails;
|
||||||
|
if (options.length > 0) {
|
||||||
|
return this.renderWithOptions(options);
|
||||||
|
}
|
||||||
|
return this.renderLoginForm();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default EnterpriseAuthenticationComponent;
|
export default EnterpriseAuthenticationComponent;
|
||||||
|
Loading…
Reference in New Issue
Block a user