mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-07 05:55:44 +01:00
add validation if number is really a number
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
import React from "react";
|
||||
import { translate } from "react-i18next";
|
||||
import { Checkbox, InputField } from "../../../components/forms/index";
|
||||
import * as validator from "../../../components/validation";
|
||||
|
||||
type Props = {
|
||||
realmDescription: string,
|
||||
@@ -20,7 +21,23 @@ type Props = {
|
||||
hasUpdatePermission: boolean
|
||||
};
|
||||
|
||||
class GeneralSettings extends React.Component<Props> {
|
||||
type State = {
|
||||
loginAttemptLimitError: boolean,
|
||||
loginAttemptLimitTimeoutError: boolean
|
||||
};
|
||||
|
||||
class GeneralSettings extends React.Component<Props, State> {
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
loginAttemptLimitError: false,
|
||||
loginAttemptLimitTimeoutError: false,
|
||||
baseUrlError: false,
|
||||
pluginUrlError: false
|
||||
};
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
t,
|
||||
@@ -75,12 +92,16 @@ class GeneralSettings extends React.Component<Props> {
|
||||
onChange={this.handleLoginAttemptLimitChange}
|
||||
value={loginAttemptLimit}
|
||||
disabled={!hasUpdatePermission}
|
||||
validationError={this.state.loginAttemptLimitError}
|
||||
errorMessage={t("validation.login-attempt-limit-invalid")}
|
||||
/>
|
||||
<InputField
|
||||
label={t("general-settings.login-attempt-limit-timeout")}
|
||||
onChange={this.handleLoginAttemptLimitTimeoutChange}
|
||||
value={loginAttemptLimitTimeout}
|
||||
disabled={!hasUpdatePermission}
|
||||
validationError={this.state.loginAttemptLimitTimeoutError}
|
||||
errorMessage={t("validation.login-attempt-limit-timeout-invalid")}
|
||||
/>
|
||||
<Checkbox
|
||||
checked={skipFailedAuthenticators}
|
||||
@@ -126,6 +147,10 @@ class GeneralSettings extends React.Component<Props> {
|
||||
this.props.onChange(true, value, "anonymousAccessEnabled");
|
||||
};
|
||||
handleLoginAttemptLimitChange = (value: string) => {
|
||||
this.setState({
|
||||
...this.state,
|
||||
loginAttemptLimitError: !validator.isNumberValid(value)
|
||||
});
|
||||
this.props.onChange(true, value, "loginAttemptLimit");
|
||||
};
|
||||
handleSkipFailedAuthenticatorsChange = (value: string) => {
|
||||
@@ -135,6 +160,10 @@ class GeneralSettings extends React.Component<Props> {
|
||||
this.props.onChange(true, value, "pluginUrl");
|
||||
};
|
||||
handleLoginAttemptLimitTimeoutChange = (value: string) => {
|
||||
this.setState({
|
||||
...this.state,
|
||||
loginAttemptLimitTimeoutError: !validator.isNumberValid(value)
|
||||
});
|
||||
this.props.onChange(true, value, "loginAttemptLimitTimeout");
|
||||
};
|
||||
handleEnabledXsrfProtectionChange = (value: boolean) => {
|
||||
|
||||
Reference in New Issue
Block a user