@@ -37,11 +37,11 @@ component {
37
37
param rc .password = " " ;
38
38
39
39
try {
40
- var token = jwt ().attempt ( rc .username , rc .password );
40
+ var token = jwtAuth ().attempt ( rc .username , rc .password );
41
41
return {
42
42
" error" : true ,
43
43
" data" : token ,
44
- " message" : " Bearer token created and it expires in #jwt ().getSettings ().jwt .expiration # minutes"
44
+ " message" : " Bearer token created and it expires in #jwtAuth ().getSettings ().jwt .expiration # minutes"
45
45
};
46
46
} catch ( " InvalidCredentials" e ) {
47
47
event .setHTTPHeader ( statusCode = 401 , statusText = " Not Authorized" );
@@ -61,11 +61,11 @@ component {
61
61
prc .oUser = populateModel ( " User" );
62
62
userService .create ( prc .oUser );
63
63
64
- var token = jwt ().fromuser ( prc .oUser );
64
+ var token = jwtAuth ().fromuser ( prc .oUser );
65
65
return {
66
66
" error" : true ,
67
67
" data" : token ,
68
- " message" : " User registered correctly and Bearer token created and it expires in #jwt ().getSettings ().jwt .expiration # minutes"
68
+ " message" : " User registered correctly and Bearer token created and it expires in #jwtAuth ().getSettings ().jwt .expiration # minutes"
69
69
};
70
70
}
71
71
@@ -83,15 +83,15 @@ component {
83
83
function gen ( event , rc , prc ){
84
84
var timestamp = now ();
85
85
var userId = 123 ;
86
- return jwt ().encode ( {
86
+ return jwtAuth ().encode ( {
87
87
// Issuing authority
88
88
" iss" : event .getHTMLBaseURL (),
89
89
// Token creation
90
- " iat" : jwt ().toEpoch ( timestamp ),
90
+ " iat" : jwtAuth ().toEpoch ( timestamp ),
91
91
// The subject identifier
92
92
" sub" : 123 ,
93
93
// The token expiration
94
- " exp" : jwt ().toEpoch ( dateAdd ( " s" , 1 , timestamp ) ),
94
+ " exp" : jwtAuth ().toEpoch ( dateAdd ( " s" , 1 , timestamp ) ),
95
95
// The unique identifier of the token
96
96
" jti" : hash ( timestamp & userId ),
97
97
// Get the user scopes for the JWT token
@@ -106,7 +106,7 @@ component {
106
106
*/
107
107
function dec ( event , rc , prc ){
108
108
var token = " eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpYXQiOjE1NjkyNzI0NjQsInJvbGUiOiJhZG1pbiIsInNjb3BlcyI6W10sImlzcyI6Imh0dHA6Ly8xMjcuMC4wLjE6NTY1OTYvIiwic3ViIjoxMjMsImV4cCI6MTU2OTI3MjQ2NSwianRpIjoiRTRDNEM3MDdFNjA1MzQwRDkxRDNCMDBCMkI4NTdFNDMifQ.N2rT_b_Xp8e9Hw0O7yVork6Fg8aC7RKf0Fv-Bmu7Iv5CVvFrmk1gkF_oKeXmcl22MiwhB2oQJhMNZiFa5OfSKw" ;
109
- return jwt ().decode ( token );
109
+ return jwtAuth ().decode ( token );
110
110
}
111
111
112
112
}
0 commit comments