Merged 2.0.0-m3

This commit is contained in:
Philipp Czora
2019-02-25 16:53:25 +01:00
753 changed files with 23810 additions and 20056 deletions

View File

@@ -15,7 +15,7 @@ import {
InputField,
SubmitButton,
ErrorNotification,
Image
Image, UnauthorizedError
} from "@scm-manager/ui-components";
import classNames from "classnames";
import { getLoginLink } from "../modules/indexResource";
@@ -92,13 +92,22 @@ class Login extends React.Component<Props, State> {
return !this.isValid();
}
areCredentialsInvalid() {
const { t, error } = this.props;
if (error instanceof UnauthorizedError) {
return new Error(t("error-notification.wrong-login-credentials"));
} else {
return error;
}
}
renderRedirect = () => {
const { from } = this.props.location.state || { from: { pathname: "/" } };
return <Redirect to={from} />;
};
render() {
const { authenticated, loading, error, t, classes } = this.props;
const { authenticated, loading, t, classes } = this.props;
if (authenticated) {
return this.renderRedirect();
@@ -119,7 +128,7 @@ class Login extends React.Component<Props, State> {
alt={t("login.logo-alt")}
/>
</figure>
<ErrorNotification error={error} />
<ErrorNotification error={this.areCredentialsInvalid()} />
<form onSubmit={this.handleSubmit}>
<InputField
placeholder={t("login.username-placeholder")}
@@ -133,7 +142,6 @@ class Login extends React.Component<Props, State> {
/>
<SubmitButton
label={t("login.submit")}
disabled={this.isInValid()}
fullWidth={true}
loading={loading}
/>