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 264264 "isStatic" : false ,
265265 "shortDescription" : " " ,
266266 "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" : " "
267287 }
268288 ],
269289 "name" : " NbEmailPassAuthProvider" ,
Original file line number Diff line number Diff line change @@ -205,6 +205,7 @@ export class NbEmailPassAuthProvider extends NbAbstractAuthProvider {
205205
206206 return res ;
207207 } ) ,
208+ this . validateToken ( 'login' ) ,
208209 map ( ( res ) => {
209210 return new NbAuthResult (
210211 true ,
@@ -245,6 +246,7 @@ export class NbEmailPassAuthProvider extends NbAbstractAuthProvider {
245246
246247 return res ;
247248 } ) ,
249+ this . validateToken ( 'register' ) ,
248250 map ( ( res ) => {
249251 return new NbAuthResult (
250252 true ,
@@ -401,6 +403,21 @@ export class NbEmailPassAuthProvider extends NbAbstractAuthProvider {
401403 ) ;
402404 }
403405
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+
404421 protected getActionEndpoint ( action : string ) : string {
405422 const actionEndpoint : string = this . getConfigValue ( `${ action } .endpoint` ) ;
406423 const baseEndpoint : string = this . getConfigValue ( 'baseEndpoint' ) ;
You can’t perform that action at this time.
0 commit comments