[coldbox-4.3.0+188] trouble using the jwt module

Hi,

This is my first installed module so maybe I’m doing something wrong. I used commandbox to install the module, as instructed: “install jwt”

and this put a jwt folder in the /modules folder and updated box.json

But when I try to run it in the view, in a way similar to the examples, like <cfset decoded = jwt.decode( token , key ) /> it says that variable JWT is undefined.

Is “jwt” not automatically available to the view?

Any help would be greatly appreciated! All I need is a way to decode a jwt.

-Don

You have successfully installed the module but you need inject the jwt component first. You can do this by injecting it into your handler (or another module)

component extends=“coldbox.system.EventHandler”{

//inject the jwt module here

property name=“jwt” inject=“JWTService@jwt”;

// Default Action

function index(event,rc,prc){

//use the module over there

var token = variables.jwt.encode( payload , key );

prc.welcomeMessage = “Welcome to ColdBox!”;

event.setView(“main/index”);

}

}

The injection dsl means that is going to look for a model name JWTService at the jwt module. (inject=“model@module”).

Use jwt.decode( token , key , [ algorithm ] ); to decode a jwt token.

Thank you, Ryan!! I didn’t realize injection was required. That did the trick!