File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed
src/framework/auth/providers Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 264
264
"isStatic" : false ,
265
265
"shortDescription" : " " ,
266
266
"description" : " "
267
+ },
268
+ {
269
+ "examples" : [],
270
+ "params" : [
271
+ {
272
+ "name" : " module" ,
273
+ "type" : " string" ,
274
+ "required" : null ,
275
+ "shortDescription" : " " ,
276
+ "description" : " "
277
+ }
278
+ ],
279
+ "platform" : null ,
280
+ "name" : " validateToken" ,
281
+ "type" : [
282
+ " any"
283
+ ],
284
+ "isStatic" : false ,
285
+ "shortDescription" : " " ,
286
+ "description" : " "
267
287
}
268
288
],
269
289
"name" : " NbEmailPassAuthProvider" ,
Original file line number Diff line number Diff line change @@ -205,6 +205,7 @@ export class NbEmailPassAuthProvider extends NbAbstractAuthProvider {
205
205
206
206
return res ;
207
207
} ) ,
208
+ this . validateToken ( 'login' ) ,
208
209
map ( ( res ) => {
209
210
return new NbAuthResult (
210
211
true ,
@@ -245,6 +246,7 @@ export class NbEmailPassAuthProvider extends NbAbstractAuthProvider {
245
246
246
247
return res ;
247
248
} ) ,
249
+ this . validateToken ( 'register' ) ,
248
250
map ( ( res ) => {
249
251
return new NbAuthResult (
250
252
true ,
@@ -401,6 +403,21 @@ export class NbEmailPassAuthProvider extends NbAbstractAuthProvider {
401
403
) ;
402
404
}
403
405
406
+ protected validateToken ( module : string ) : any {
407
+ return map ( ( res ) => {
408
+ const token = this . getConfigValue ( 'token.getter' ) ( module , res ) ;
409
+ if ( ! token ) {
410
+ const key = this . getConfigValue ( 'token.key' ) ;
411
+ console . warn ( `NbEmailPassAuthProvider:
412
+ Token is not provided under '${ key } ' key
413
+ with getter '${ this . getConfigValue ( 'token.getter' ) } ', check your auth configuration.` ) ;
414
+
415
+ throw new Error ( 'Could not extract token from the response.' ) ;
416
+ }
417
+ return res ;
418
+ } ) ;
419
+ }
420
+
404
421
protected getActionEndpoint ( action : string ) : string {
405
422
const actionEndpoint : string = this . getConfigValue ( `${ action } .endpoint` ) ;
406
423
const baseEndpoint : string = this . getConfigValue ( 'baseEndpoint' ) ;
You can’t perform that action at this time.
0 commit comments