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

Register Link 'broken' after login when using AccountsTemplates.ensureSignedIn #52

Open
zcrowe opened this issue Oct 19, 2016 · 3 comments

Comments

@zcrowe
Copy link

zcrowe commented Oct 19, 2016

Hello!

I have a route setup as follows:

FlowRouter.route('/', {
  triggersEnter: [AccountsTemplates.ensureSignedIn],
  name: 'home',
  action(params, queryParams) {
    BlazeLayout.render('dashboard', {main: 'deviceList'});
  },
});

Which redirect to /login-in:

AccountsTemplates.configureRoute('signIn', {
  name: 'login',
  path: '/login'
});

If the 'Register' link is clicked, the register form works, and does allow the user to login. I've noticed the URL does not change to /sign-up as expected. Registering does 'work' but the notification confirming registration and to check their email to confirm is only displayed for a split second before they are sent back to the signup form.

Is this a bug or is my accounts templates setup wrong?

Here it is in case it helps :)

// Documentation: https://github.com/meteor-useraccounts/core/blob/master/Guide.md
AccountsTemplates.configure({
  defaultLayout: 'auth',
  defaultContentRegion: 'main',
  defaultLayoutRegions: {},

  // Behavior
  confirmPassword: true,
  enablePasswordChange: true,
  sendVerificationEmail: true,
  // WARNING - see docs, this may not work with federated logins
  enforceEmailVerification: true,
  focusFirstInput: true,

  // Appearance
  showForgotPasswordLink: true,
  showResendVerificationEmailLink: true,

  // Client-side Validation
  continuousValidation: true,

  // Redirects
  //homeRoutePath: 'login',

  // Hooks
  onLogoutHook: function () {
    FlowRouter.go('login');
  },

  // Text
  texts: {
    title: {
      resendVerificationEmail: "Enter you email below and we'll resend your verification email",
    }
  }
});

AccountsTemplates.addField({
  _id: 'username',
  'displayName': 'Display Name',
  type: 'text',
  placeholder: {
      signUp: "Suitable for public display, must be unique!"
  },
  required: true,
  minLength: 3,
  re: /^[a-zA-Z0-9]+$/,
  errStr: 'Username is required',
});


//Documentation: https://github.com/meteor-useraccounts/flow-routing
AccountsTemplates.configureRoute('signIn', {
  name: 'login',
  path: '/login'
});

AccountsTemplates.configureRoute('signUp');

AccountsTemplates.configureRoute('forgotPwd');

AccountsTemplates.configureRoute('resetPwd', {
  name: 'resetPwd',
  path: '/reset-password'
});

AccountsTemplates.configureRoute('changePwd', {
  name: 'changePwd',
  path: '/settings',
  layoutTemplate: 'dashboard',
  contentRegion: 'main',
  layoutRegions: {},
  homeRoutePath: 'home',
});

AccountsTemplates.configureRoute('verifyEmail', {
  name: 'verifyEmail',
  path: '/verify-email',
  layoutTemplate: 'dashboard',
  contentRegion: 'main',
  layoutRegions: {},
  homeRoutePath: 'home',
});

@zcrowe
Copy link
Author

zcrowe commented Nov 2, 2016

Any one got any insights they can offer?

@roelvan
Copy link

roelvan commented Jul 31, 2018

got this too +1

@roelvan
Copy link

roelvan commented Jul 31, 2018

This dirty hack should fix the problem @zcrowe:
Create a file eg. at-form.js:

Template.atForm.onCreated(function() {
  const template = this;
  template.autorun(() => {
    if (AccountsTemplates.getState() === 'signUp') {
      FlowRouter.go('/register') // your registration url path
    }
  });
});

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