Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Cancel' link in Change Password view does not use config.loginPath #109

Open
premasagar opened this issue Apr 11, 2017 · 1 comment
Open

Comments

@premasagar
Copy link
Contributor

premasagar commented Apr 11, 2017

I have routes for /change-password and /login (using React Router), which render Accounts.ui.LoginForm.

// config
Accounts.ui.config({
  changePasswordPath: '/change-password',
  loginPath: '/login'
  // ...
});

On the Change Password view, clicking 'Cancel' correctly changes the form fields to the login state, but does not update the route URL. Probably related to #83

Temporary workaround:
Extend Accounts.ui.LoginForm and supply a new buttons() method:

class LoginForm extends Accounts.ui.LoginForm {
  buttons () {
    const buttons = super.buttons();
    const {loginPath} = Accounts.ui._options;

    if (loginPath && 'cancelResetPassword' in buttons) {
      buttons.cancelResetPassword.href = loginPath;
    }

    return buttons;
  }
}

Accounts.ui.LoginForm = LoginForm;
@jlmbaka
Copy link

jlmbaka commented Sep 28, 2017

@premasagar Thank you for the workaround, I was able to get to a good enough solution thanks to it. However unlike you, I wasn't able to make the cancel button work by setting the href property. Instead, I overwrote the onClick callback to redirect to where I wanted.

Here's an example. I am able to access history by using the withHistory HOC from React-Router@4.

import { Accounts } from 'meteor/std:accounts-ui';
import { withRouter } from 'react-router';

class LoginForm extends Accounts.ui.LoginForm {
  buttons () {
    const buttons = super.buttons();
    const { loginPath } = Accounts.ui._options;
    const { history } = this.props;

    if (loginPath && 'cancelResetPassword' in buttons) {
      buttons.cancelResetPassword.onClick = () => history.push(loginPath);
    }
    return buttons;
  }
}
export default withRouter(LoginForm);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants