diff --git a/app/components/elements/Template.jsx b/app/components/elements/Template.jsx index 7b341d143eff03a4bcc6994db60a348817362b7e..52132f3e489401074fee651b1980a6f56c79ad5e 100644 --- a/app/components/elements/Template.jsx +++ b/app/components/elements/Template.jsx @@ -31,6 +31,7 @@ class Template extends React.Component { // } // componentWillUpdate(nextProps, nextState) { + // // Can't call this.setState() here, use componentWillReceiveProps instead // } // componentDidUpdate(prevProps, prevState) { diff --git a/app/components/modules/LoginForm.jsx b/app/components/modules/LoginForm.jsx index 0ec72d1849e5c71f2ac60d8b7a64aef59083e8cf..9c5fb2ace7b816bdee2eb74322f372a87c855ef8 100644 --- a/app/components/modules/LoginForm.jsx +++ b/app/components/modules/LoginForm.jsx @@ -1,7 +1,7 @@ /* eslint react/prop-types: 0 */ import React, { PropTypes, Component } from 'react'; import ReactDOM from 'react-dom'; -import {PublicKey} from 'shared/ecc' +import {PublicKey, PrivateKey} from 'shared/ecc' import transaction from 'app/redux/Transaction' import g from 'app/redux/GlobalReducer' import user from 'app/redux/User' @@ -155,6 +155,11 @@ class LoginForm extends Component { </div>; } } + const standardPassword = checkPasswordChecksum(password.value) + const password_info = standardPassword === undefined ? null : + standardPassword ? 'Password checks out and appears valid.' : + 'This password was probably typed or copied incorrectly.' + const form = ( <form onSubmit={handleSubmit(data => { // bind redux-form to react-redux @@ -173,6 +178,7 @@ class LoginForm extends Component { <div> <input type="password" required ref="pw" placeholder="Password or WIF" {...password.props} autoComplete="on" disabled={submitting} /> <div className="error">{error} </div> + {password_info && <div className="warning">{password_info} </div>} </div> {loginBroadcastOperation && <div> <div className="info">This operation requires your {authType} key (or use your master password).</div> @@ -219,6 +225,15 @@ function urlAccountName() { return suggestedAccountName } +function checkPasswordChecksum(password) { + if(!/^P.{45,}/.test(password)) {// 52 is the length + // not even close + return undefined + } + const wif = password.substring(1) + return PrivateKey.isWif(wif) +} + import {connect} from 'react-redux' export default connect(