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

jwt config is undefined #11

Closed
ghost opened this issue Aug 5, 2014 · 3 comments
Closed

jwt config is undefined #11

ghost opened this issue Aug 5, 2014 · 3 comments
Labels

Comments

@ghost
Copy link

ghost commented Aug 5, 2014

waterlock/lib/controllers/actions/jwt.js
var moment = require('moment');
var config = require('../../waterlock').config;
var uuid = require('node-uuid');
var jwt = require('jwt-simple');

/**

  • jwt action
  • creates a new token if a session is authenticated
  • GET /user/jwt
    _/
    module.exports = function(req, res){
    _console.log(config); //this prints 'undefined'*
    if(!req.session.authenticated){
    return res.forbidden('You are not authorized.');
    }

Hey davidrivera, when i try to get the json web token of a authenticated user i get a 500 error
TypeError: Cannot read property 'jsonWebTokens' of undefined at module.exports
(/home/ubuntu/workspace/radapi/node_modules/waterlock/lib/controllers/actions/jwt.js:21:26)

i place a console.log to see what was coming in that value. and it comes undefined.
but when i lift sails it shows the proper information.

@duhruh
Copy link
Member

duhruh commented Aug 5, 2014

ah good catch! I'll push out a fix asap for this. For now you can replace this line with the following

 var jsonConfig = waterlock.config.jsonWebTokens || {};

let me know if this helps. Oh and thanks!

@duhruh duhruh added the bug label Aug 5, 2014
@ghost
Copy link
Author

ghost commented Aug 5, 2014

yeah that worked!

i had to change as well
the following lines

var token = jwt.encode({
iss: user.id + '|' + req.remoteAddress,
sub: jsonConfig.subject,

**aud: jsonConfig.audience,**

exp: expires,
nbf: issued,
iat: issued,    
jti: uuid.v1()

}, jsonConfig.secret);

@duhruh
Copy link
Member

duhruh commented Aug 5, 2014

Alright this should be fixed on the master branch, thanks again man! 😄

@duhruh duhruh closed this as completed Aug 5, 2014
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

1 participant