Giter Site home page Giter Site logo

Comments (3)

devinivy avatar devinivy commented on July 18, 2024

Looks like it's due to some inconsistent error-handling around here: https://github.com/blinkmobile/hapi-oauth2orize/blob/master/index.js#L81-L98 . Your code generated an error which propagated down into a duplicate call to reply(). This area of the code clearly needs a little bit of love :)

from hapi-oauth2orize.

pabshazon avatar pabshazon commented on July 18, 2024

Yes, the error inconsistently handled is that I was missing ?response_type= in the call.

Now I'm getting the same "reply called twice" because of a simple error of "cannot read property find of undefined", I suppose I need to create my own models now for clients, tokens, etc... instead of using the example code :)

Do you have any suggestion how to fix this error? Any related documentation or approach?
Usually I understand I cannot reply twice inside a function so I separate the two reply calls by and if else, but here the two reply calls are being made from different functions (inside and callback of oauth.authorize()).

My approach would be modifying the callback of authorize(request, reply, callback(req, res)) so it passes a variable called error with req and es and then we can if/else the two different replies with error or view.

Comments welcome!

from hapi-oauth2orize.

pabshazon avatar pabshazon commented on July 18, 2024

I have improved the code a little bit with this in my code (modifying the example code from README and commenting a line in index.js (169))

Comment this line, so we can see the actual error message:
https://github.com/blinkmobile/hapi-oauth2orize/blob/master/index.js#L169

Modify the oauth.authorize() callback like this, adding if(!request.response.isBoom)

    authorize: function (request, reply) {
      oauth.authorize(request, reply, function (req, res) {
        if(!request.response.isBoom) {
          reply.view('oauth', {transactionID: req.app.transactionID});
        }
      }, function (clientID, redirect, done) {
        server.helpers.find('client', clientID, function (docs) {
          done(null, docs[0], docs[0].redirect_uri);
        });
      });
    },

So far working for me... but I'm showing some internal errors in the API output haha.
Maybe you can just not comment the line 169 so we "hide" the error from api users, but we still need a way to throw the error with the stack trace in console then.

from hapi-oauth2orize.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.