lookaflyingdonkey / ah-jwtauth-plugin

ActionHero plugin to add bare bone JSON Web Token (JWT) support
8 stars 11 forks source link

api.jwtauth === undefined #1

Open peterkingsbury opened 8 years ago

peterkingsbury commented 8 years ago

Hello,

Going through the GitHub documentation, and trying to access api.jwtauth, but the variable is not present!

I'm using AH 12.0

I also noticed that data.connection.user is not present in my actions/authenticate.js when triggered from the client.

Some guidance would be great!

Thanks,

ifavo commented 8 years ago

Hi Peter,

I've forked it and setup a compatible version here: https://github.com/ifavo/ah-jwtauth-plugin/

You can install the fork until the pull request has been approved.

Cheers, Mario

krlicmuhamed commented 8 years ago

Hello @ifavo,

Your new ah-jwtauth2-plugin still has the issue of api.jwtauth being undefined. I really don't understand why is that so. But here is my output:

actionhero start
info: actionhero >> start
2015-12-11 19:55:55 - notice: *** starting actionhero ***
2015-12-11 19:55:55 - info: actionhero member 192.168.0.11 has joined the cluster

/root/Projects/nodejs/ima-license-server/initializers/master.js:7
    api.jwtauth.generateToken({master:'key'}, function(token) {
                ^
TypeError: Cannot call method 'generateToken' of undefined
    at Object.module.exports.initialize (/root/Projects/nodejs/ima-license-server/initializers/master.js:7:17)
    at loadFunction (/root/Projects/nodejs/ima-license-server/node_modules/actionhero/actionhero.js:108:44)
    at /root/Projects/nodejs/ima-license-server/node_modules/async/lib/async.js:713:13
    at Object.iterate [as _onImmediate] (/root/Projects/nodejs/ima-license-server/node_modules/async/lib/async.js:262:13)
    at processImmediate [as _immediateCallback] (timers.js:336:15)

Here's a gist for more detailed look at this.

krlicmuhamed commented 8 years ago

It turns out I got these as I am pretty new to actionhero and plugin didn't match the design pattern that @evantahler ( founder of actionhero ) originally had in mind. @ifavo I made a pull request adding some final touches to make It a bit more newbie proof.