// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import React from 'react';
import AdminSettings from './admin_settings.jsx';
import {FormattedMessage} from 'react-intl';
import SettingsGroup from './settings_group.jsx';
import TextSetting from './text_setting.jsx';
import Setting from './setting.jsx';
import * as Utils from 'utils/utils.jsx';
import Constants from 'utils/constants.jsx';
import GeneratedSetting from './generated_setting.jsx';
export default class PasswordSettings extends AdminSettings {
constructor(props) {
super(props);
this.getConfigFromState = this.getConfigFromState.bind(this);
this.renderSettings = this.renderSettings.bind(this);
this.getSampleErrorMsg = this.getSampleErrorMsg.bind(this);
this.handlePasswordLengthChange = this.handlePasswordLengthChange.bind(this);
this.handleCheckboxChange = this.handleCheckboxChange.bind(this);
this.state = Object.assign(this.state, {
passwordMinimumLength: props.config.PasswordSettings.MinimumLength,
passwordLowercase: props.config.PasswordSettings.Lowercase,
passwordNumber: props.config.PasswordSettings.Number,
passwordUppercase: props.config.PasswordSettings.Uppercase,
passwordSymbol: props.config.PasswordSettings.Symbol,
maximumLoginAttempts: props.config.ServiceSettings.MaximumLoginAttempts,
passwordResetSalt: props.config.EmailSettings.PasswordResetSalt
});
// Update sample message from config settings
this.sampleErrorMsg = null;
if (global.window.mm_license.IsLicensed === 'true' && global.window.mm_license.PasswordRequirements === 'true') {
let sampleErrorMsgId = 'user.settings.security.passwordError';
if (props.config.PasswordSettings.Lowercase) {
sampleErrorMsgId = sampleErrorMsgId + 'Lowercase';
}
if (props.config.PasswordSettings.Uppercase) {
sampleErrorMsgId = sampleErrorMsgId + 'Uppercase';
}
if (props.config.PasswordSettings.Number) {
sampleErrorMsgId = sampleErrorMsgId + 'Number';
}
if (props.config.PasswordSettings.Symbol) {
sampleErrorMsgId = sampleErrorMsgId + 'Symbol';
}
this.sampleErrorMsg = (