<commit_before>import _ from 'lodash';
import Formsy from 'formsy-react';
import React from 'react';
import request from 'superagent';
import SecurePage from '../secure-page';
import TextBox from '../forms/text-box';

class ChangePassword extends React.Component {
	constructor(props) {
		super(props);
		this.onSubmit = this.onSubmit.bind(this);
	}

	onSubmit(model, resetForm) {
		request
			.put(`/api/1.0/users/${this.props.username}/password/`)
			.send(_.pick(model, ['oldPassword', 'newPassword']))
			.end((err, res) => {
				if (err) {
					return this.props.flashError(
							res.body.title || 'A general server error has occurred and your password could not be changed. Please try again later.',
							res.body.description);
				}

				resetForm();
				this.props.flashInfo('Your password was successfully changed.');
			});
	}

	render() {
		return (
			<SecurePage>
				<h2>Change Password</h2>
				<Formsy.Form onValidSubmit={ this.onSubmit }>
					<TextBox
						id="oldPassword"
						name="oldPassword"
						type="password"
						label="Old password"
						value=""
						required />

					<TextBox
						id="newPassword"
						name="newPassword"
						type="password"
						label="New password"
						value=""
						validations={ {
							matchRegexp: window.appSettings.passwordStrengthRegex
						} }
						validationErrors={ {
							matchRegexp: 'Password does not meet strength requirements. It must contain a letter, a number, a special character and be at least 7 characters long.'
						} }
						required />

					<TextBox
						id="confirmPassword"
						name="confirmPassword"
						type="password"
						label="Confirm password"
						value=""
						validation={ {
							equalsField: 'newPassword'
						} }
						validationErrors={ {
							equalsField: 'Passwords do not match.'
						} }
						required />

					<button type="submit">Change Password</button>
				</Formsy.Form>
			</SecurePage>);<commit_msg>Improved look of Change Password page.<commit_after>import _ from 'lodash';
import Formsy from 'formsy-react';
import React from 'react';
import request from 'superagent';
import SecurePage from '../secure-page';
import TextBox from '../forms/text-box';

import { Button, ButtonToolbar, Col, PageHeader, Row } from 'react-bootstrap';

class ChangePassword extends React.Component {
	constructor(props) {
		super(props);
		this.onSubmit = this.onSubmit.bind(this);
	}

	onSubmit(model, resetForm) {
		request
			.put(`/api/1.0/users/${this.props.username}/password/`)
			.send(_.pick(model, ['oldPassword', 'newPassword']))
			.end((err, res) => {
				if (err) {
					return this.props.flashError(
							res.body.title || 'A general server error has occurred and your password could not be changed. Please try again later.',
							res.body.description);
				}

				resetForm();
				this.props.flashInfo('Your password was successfully changed.');
			});
	}

	render() {
		return (
			<SecurePage>
				<PageHeader>Change Password</PageHeader>
				<Row>
					<Col lg={ 4 } sm={ 12 }>
						<Formsy.Form onValidSubmit={ this.onSubmit }>
							<TextBox
								id="oldPassword"
								name="oldPassword"
								type="password"
								label="Old password"
								value=""
								required />

							<TextBox
								id="newPassword"
								name="newPassword"
								type="password"
								label="New password"
								value=""
								validations={ {
									matchRegexp: window.appSettings.passwordStrengthRegex
								} }
								validationErrors={ {
									matchRegexp: 'Password does not meet strength requirements. It must contain a letter, a number, a special character and be at least 7 characters long.'
								} }
								required />

							<TextBox
								id="<PASSWORD>Password"
								name="confirmPassword"
								type="password"
								label="Confirm password"
								value=""
								validations={ {
									equalsField: 'newPassword'
								} }
								validationErrors={ {
									equalsField: 'Passwords do not match.'
								} }
								required />

							<ButtonToolbar>
								<Button bsStyle="primary" type="submit">Change Password</Button>
							</ButtonToolbar>
						</Formsy.Form>
					</Col>
				</Row>
			</SecurePage>);
{'fraction_non_alphanumeric': 0.12784629981024667, 'fraction_numerical': 0.0026091081593927895, 'mean_word_length': 2.6042735042735043, 'pattern_counts': {'":': 0, '<': 32, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5211289', 'n_tokens_mistral': 1760, 'n_tokens_neox': 1194, 'n_words': 309}