resolve promise on pair
This commit is contained in:
		
							parent
							
								
									06b894a99d
								
							
						
					
					
						commit
						a9353a9a75
					
				@ -203,6 +203,9 @@ module.exports.pairPin = function (opts) {
 | 
				
			|||||||
    var pathname = path.join(__dirname, 'emails', auth.subject + '.' + hrname + '.data');
 | 
					    var pathname = path.join(__dirname, 'emails', auth.subject + '.' + hrname + '.data');
 | 
				
			||||||
    auth.authz = jwt.sign(authzData, state.secret);
 | 
					    auth.authz = jwt.sign(authzData, state.secret);
 | 
				
			||||||
    authzData.jwt = auth.authz;
 | 
					    authzData.jwt = auth.authz;
 | 
				
			||||||
 | 
					    if (auth.resolve) {
 | 
				
			||||||
 | 
					      auth.resolve(auth);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    fs.writeFile(pathname, JSON.stringify(authzData), function (err) {
 | 
					    fs.writeFile(pathname, JSON.stringify(authzData), function (err) {
 | 
				
			||||||
      if (err) {
 | 
					      if (err) {
 | 
				
			||||||
        console.error('[ERROR] in writing token details');
 | 
					        console.error('[ERROR] in writing token details');
 | 
				
			||||||
@ -237,8 +240,17 @@ module.exports.authenticate = function (opts) {
 | 
				
			|||||||
      // multiple times (or something else goes wrong)
 | 
					      // multiple times (or something else goes wrong)
 | 
				
			||||||
      // this will cause the websocket to disconnect
 | 
					      // this will cause the websocket to disconnect
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      auth.resolve = resolve;
 | 
					      auth.resolve = function (auth) {
 | 
				
			||||||
      auth.reject = reject;
 | 
					        opts.auth = auth.authz;
 | 
				
			||||||
 | 
					        auth.resolve = null;
 | 
				
			||||||
 | 
					        auth.reject = null;
 | 
				
			||||||
 | 
					        return state.defaults.authenticate(opts.auth).then(resolve);
 | 
				
			||||||
 | 
					      };
 | 
				
			||||||
 | 
					      auth.reject = function (err) {
 | 
				
			||||||
 | 
					        auth.resolve = null;
 | 
				
			||||||
 | 
					        auth.reject = null;
 | 
				
			||||||
 | 
					        reject(err);
 | 
				
			||||||
 | 
					      };
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return auth.promise;
 | 
					    return auth.promise;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user