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 do I override the displayRegister method in password.js? #440

Open
bbeny opened this issue Aug 29, 2013 · 0 comments
Open

How do I override the displayRegister method in password.js? #440

bbeny opened this issue Aug 29, 2013 · 0 comments
Labels

Comments

@bbeny
Copy link

bbeny commented Aug 29, 2013

Here is the code in password.js I am talking about:

  .get('getRegisterPath', "the registration page's uri path.")
    .step('displayRegister')
      .accepts('req res next')
      .promises(null)
  .displayRegister(function (req, res) {
    console.log('\r\n displayRegister base');
    return renderRegister.apply(this, arguments);
  })

Here is how I thought it could be overriden in my everyauth code:

  .getRegisterPath('/registeruser')
  .displayRegister(function (req, res) {
    console.log('\r\n displayRegister child');
  })
  .postRegisterPath('/registeruser')
  .registerView('landing/login/register_user.jade')
  .registerLocals(function (req, res, done) {
    setTimeout(function () {
      done(null, { title: 'Async Register' });
    }, 200);
  })

This is all fine and my 'console.log('\r\n displayRegister child');' gets called. But, the problem is the base method in password.js needs to be called as well.

I've tried the following and it didn't work:

  .displayRegister(function (req, res) {
    console.log('\r\n displayRegister child');
    this._super();
  })

Basically, how do I call the base implementation of the method?

The reason I am doing this is because I want to inject some custom business logic before allowing access to the registeruser path. I want to make sure the user is logged in and belongs to an 'administrator' role. So, basically, I am hiding the registeruser path for non admins. I know this is probably not how everyauth registration is intended to work, but I am wondering if it can be done using the displayRegister method.

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

No branches or pull requests

2 participants