File tree Expand file tree Collapse file tree 3 files changed +13
-12
lines changed Expand file tree Collapse file tree 3 files changed +13
-12
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ var fns = [
31
31
checkClient ,
32
32
checkGrantTypeAllowed ,
33
33
checkGrantType ,
34
- exposeParams ,
34
+ exposeUser ,
35
35
generateAccessToken ,
36
36
saveAccessToken ,
37
37
generateRefreshToken ,
@@ -132,6 +132,7 @@ function credsFromBody (req) {
132
132
* @this OAuth
133
133
*/
134
134
function checkClient ( done ) {
135
+ var self = this ;
135
136
this . model . getClient ( this . client . clientId , this . client . clientSecret ,
136
137
function ( err , client ) {
137
138
if ( err ) return done ( error ( 'server_error' , false , err ) ) ;
@@ -140,6 +141,9 @@ function checkClient (done) {
140
141
return done ( error ( 'invalid_client' , 'Client credentials are invalid' ) ) ;
141
142
}
142
143
144
+ // Expose validated client
145
+ self . req . oauth = { client : client } ;
146
+
143
147
done ( ) ;
144
148
} ) ;
145
149
}
@@ -344,17 +348,12 @@ function checkGrantTypeAllowed (done) {
344
348
}
345
349
346
350
/**
347
- * Expose user and client params
351
+ * Expose user
348
352
*
349
353
* @param {Function } done
350
354
* @this OAuth
351
355
*/
352
- function exposeParams ( done ) {
353
- this . req . oauth = this . req . oauth || { } ;
354
- this . req . oauth . client = {
355
- id : this . client . clientId ,
356
- secret : this . client . clientSecret
357
- } ;
356
+ function exposeUser ( done ) {
358
357
this . req . user = this . user ;
359
358
360
359
done ( ) ;
Original file line number Diff line number Diff line change @@ -121,12 +121,14 @@ describe('Granting with extended grant type', function () {
121
121
var app = bootstrap ( {
122
122
model : {
123
123
getClient : function ( id , secret , callback ) {
124
- callback ( false , true ) ;
124
+ callback ( false , { clientId : 'thom' , clientSecret : 'nightworld' } ) ;
125
125
} ,
126
126
grantTypeAllowed : function ( clientId , grantType , callback ) {
127
127
callback ( false , true ) ;
128
128
} ,
129
129
extendedGrant : function ( grantType , req , callback ) {
130
+ req . oauth . client . clientId . should . equal ( 'thom' ) ;
131
+ req . oauth . client . clientSecret . should . equal ( 'nightworld' ) ;
130
132
callback ( false , true , { id : 3 } ) ;
131
133
} ,
132
134
saveAccessToken : function ( ) {
Original file line number Diff line number Diff line change @@ -256,7 +256,7 @@ describe('Grant', function() {
256
256
var app = bootstrap ( {
257
257
model : {
258
258
getClient : function ( id , secret , callback ) {
259
- callback ( false , true ) ;
259
+ callback ( false , { clientId : 'thom' , clientSecret : 'nightworld' } ) ;
260
260
} ,
261
261
grantTypeAllowed : function ( clientId , grantType , callback ) {
262
262
callback ( false , true ) ;
@@ -265,8 +265,8 @@ describe('Grant', function() {
265
265
callback ( false , { id : 1 } ) ;
266
266
} ,
267
267
generateToken : function ( type , req , callback ) {
268
- req . oauth . client . id . should . equal ( 'thom' ) ;
269
- req . oauth . client . secret . should . equal ( 'nightworld' ) ;
268
+ req . oauth . client . clientId . should . equal ( 'thom' ) ;
269
+ req . oauth . client . clientSecret . should . equal ( 'nightworld' ) ;
270
270
req . user . id . should . equal ( 1 ) ;
271
271
callback ( false , 'thommy' ) ;
272
272
} ,
You can’t perform that action at this time.
0 commit comments