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

Bug in example postgres model.js. #47

Open
IhorHryshkov opened this issue Mar 2, 2017 · 1 comment
Open

Bug in example postgres model.js. #47

IhorHryshkov opened this issue Mar 2, 2017 · 1 comment

Comments

@IhorHryshkov
Copy link

IhorHryshkov commented Mar 2, 2017

module.exports.getAccessToken = function(bearerToken) {
  return pg.query('SELECT access_token, access_token_expires_on, client_id, refresh_token, refresh_token_expires_on, user_id FROM oauth_tokens WHERE access_token = $1', [bearerToken])
    .then(function(result) {
      var token = result.rows[0];

      return {
        accessToken: token.access_token,
        clientId: token.client_id,
        expires: token.expires,  // This position
        userId: token.userId  //And this position
      };
    });
};

Please fix it to:

module.exports.getAccessToken = function(bearerToken) {
  return pg.query('SELECT access_token, access_token_expires_on, client_id, refresh_token, refresh_token_expires_on, user_id FROM oauth_tokens WHERE access_token = $1', [bearerToken])
    .then(function(result) {
      var token = result.rows[0];

      return {
        accessToken: token.access_token,
        clientId: token.client_id,
        expires: token.access_token_expires_on,
        userId: token.user_id
      };
    });
};

Or:

module.exports.getAccessToken = function(bearerToken) {
  return pg.query('SELECT access_token, access_token_expires_on AS expires, client_id, refresh_token, refresh_token_expires_on, user_id AS userId FROM oauth_tokens WHERE access_token = $1', [bearerToken])
    .then(function(result) {
      var token = result.rows[0];

      return {
        accessToken: token.access_token,
        clientId: token.client_id,
        expires: token.expires,
        userId: token.userId
      };
    });
};
@mjsalinger
Copy link
Contributor

Could you take this code and create a PR for it?

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