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

How to redirect after password change #113

Open
kolyasya opened this issue Apr 18, 2017 · 1 comment
Open

How to redirect after password change #113

kolyasya opened this issue Apr 18, 2017 · 1 comment

Comments

@kolyasya
Copy link

I've setup user accounts and added basic pages.

I've made my Profile page with a link to change-password page. When I open it I see:

image

After changing password I get

image

I've tried to find any options to redirect user after successful password change, but have no luck.
Also I've tried to redirect user manually via History object, but I'm staying on the same page.

Here is my current accounts.ui config:

Accounts.ui.config({
  passwordSignupFields: 'EMAIL_ONLY',
  loginPath: '/sign-in',
  signUpPath: '/sign-up',
  resetPasswordPath: '/reset-password',
  changePasswordPath: '/change-password',
  profilePath: '/profile',
  homeRoutePath: '/',
  minimumPasswordLength: 6,
});

And React Router 4 routes (RouteLayout is just wrapper function around default Route component)

<RouteLayout layoutProps={{account: true}} path="/sign-in" component={() => 
  <div className="container"><Accounts.ui.LoginForm /></div>} />
<RouteLayout layoutProps={{account: true}} path="/sign-up" component={() => 
  <div className="container"><Accounts.ui.LoginForm formState={STATES.SIGN_UP} /></div>} />
<RouteLayout layoutProps={{account: true}} path="/change-password" component={() => 
  <div className="container"><Accounts.ui.LoginForm formState={STATES.PASSWORD_CHANGE} /></div>} />
<RouteLayout layoutProps={{account: true}} path="/reset-password" component={() => 
  <div className="container"><Accounts.ui.LoginForm formState={STATES.PASSWORD_RESET} /></div>} />
@capi1O
Copy link

capi1O commented Nov 20, 2018

I faced the same issue and could not find a solution so I added a redirect (I am using React Router v4) in onSubmitHook callback :

<Accounts.ui.LoginForm
   onSubmitHook={(error, formState) => this.props.history.push('/some-url)}
/>

You can check for formState in the callback to redirect to different URLs depending if its a login or enroll etc...

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