forgot password

This commit is contained in:
Belen Curcio
2018-05-04 13:34:20 -03:00
parent 9d47d3ff91
commit eabcbc36c6
3 changed files with 47 additions and 7 deletions
@@ -125,6 +125,23 @@ class ChangePassword extends React.Component {
this.disableEditing();
};
onForgotPassword = async () => {
const { root: { me: { email } } } = this.props;
try {
await this.props.forgotPassword(email);
this.props.notify(
'success',
t('talk-plugin-local-auth.change_password.forgot_password_sent')
);
} catch (err) {
this.props.notify('error', getErrorMessages(err));
}
this.clearForm();
this.disableEditing();
};
disableEditing = () => {
this.setState({
editing: false,
@@ -166,7 +183,10 @@ class ChangePassword extends React.Component {
showErrors
>
<span className={styles.detailBottomBox}>
<a className={styles.detailLink}>
<a
className={styles.detailLink}
onClick={this.onForgotPassword}
>
{t('talk-plugin-local-auth.change_password.forgot_password')}
</a>
</span>
@@ -223,6 +243,7 @@ class ChangePassword extends React.Component {
ChangePassword.propTypes = {
changePassword: PropTypes.func.isRequired,
forgotPassword: PropTypes.func.isRequired,
notify: PropTypes.func.isRequired,
};
@@ -1,12 +1,29 @@
import { compose } from 'react-apollo';
import { compose, gql } from 'react-apollo';
import { bindActionCreators } from 'redux';
import { connect } from 'plugin-api/beta/client/hocs';
import { connect, withFragments } from 'plugin-api/beta/client/hocs';
import ChangePassword from '../components/ChangePassword';
import { notify } from 'coral-framework/actions/notification';
import { withChangePassword } from 'plugin-api/beta/client/hocs';
import {
withChangePassword,
withForgotPassword,
} from 'plugin-api/beta/client/hocs';
const mapDispatchToProps = dispatch => bindActionCreators({ notify }, dispatch);
export default compose(connect(null, mapDispatchToProps), withChangePassword)(
ChangePassword
);
const withData = withFragments({
root: gql`
fragment TalkPluginLocalAuth_ChangePassword_root on RootQuery {
me {
id
email
}
}
`,
});
export default compose(
connect(null, mapDispatchToProps),
withChangePassword,
withForgotPassword,
withData
)(ChangePassword);
@@ -9,6 +9,7 @@ en:
cancel: "Cancel"
edit: "Edit"
changed_password_msg: "Changed Password - Your password has been successfully changed"
forgot_password_sent: "Forgot Password - We sent you an email to recover your password"
change_username:
change_username_note: "Usernames can be changed every 14 days"
save: "Save"
@@ -46,6 +47,7 @@ es:
cancel: "Cancelar"
edit: "Editar"
changed_password_msg: "Contraseña Actualizada - Tu contraseña ha sido exitosamente actualizada"
forgot_password_sent: "Contraseña Olvidada - Te enviamos un email para recuperar tu contraseña"
change_username:
change_username_note: "El usuario puede ser cambiado cada 14 días"
save: "Guardar"