Every line of 'axios rejectunauthorized' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
102 function isUnauthorizedDueToExpiredAccessToken(response) { 103 // There are three cases to consider: 104 // 1) The response body is a Buffer. This indicates that the request was malformed (i.e. malformed url) so return false. 105 // 2) The status code is UNAUTHORIZED and the response body is an empty object or null. This indicates that the access tokens are expired, so return true. 106 // 3) The status code is UNAUTHORIZED and the response body is a non-empty object. This indicates that the 401 was returned for some reason other 107 // than expired tokens, so return false. 108 109 if (Buffer.isBuffer(response.body)) { 110 return false; 111 } 112 113 var isResponseStatusCodeUnauthorized = response.statusCode === httpStatusCodes.UNAUTHORIZED, 114 isResponseBodyEmpty = !response.body || Object.getOwnPropertyNames(response.body).length === 0; 115 return isResponseStatusCodeUnauthorized && isResponseBodyEmpty; 116 }
31 export function unauthorizedHttpInterceptor($q: IQService, $injector: IInjectorService, $state: any) { 32 return { 33 responseError: function (rejection) { 34 if (rejection.status === 401) { 35 const toastService: ToastService = $injector.get('toastService'); 36 toastService.danger('You are currently not authorized to view this page.'); 37 38 const userService: UserService = $injector.get('userService'); 39 userService.logout(); 40 41 $state.go('root'); 42 } 43 return $q.reject(rejection); 44 } 45 }; 46 }
14 function checkUnauthorized(body) { 15 return body.statusCode === 'ERROR' && body.messages && body.messages.error && body.messages.error.length > 0 && body.messages.error[0] === 'Unauthorized access' 16 }
149 export function throw__unauthorized(ctx, ...ARR__ctx__error) { 150 log(`${logPrefix}|throw__unauthorized`) 151 throw__error( 152 ctx, 153 { 154 type: 'unauthorized', 155 error_message: 'Unauthorized', 156 status__http: 401, 157 error_message__http: 'Unauthorized' 158 }, 159 ...ARR__ctx__error) 160 }
49 function unauthorized() { 50 var req = https.request({ 51 port: common.PORT, 52 rejectUnauthorized: false 53 }, function(res) { 54 assert(!req.socket.authorized); 55 res.resume(); 56 rejectUnauthorized(); 57 }); 58 req.on('error', function(err) { 59 throw err; 60 }); 61 req.end(); 62 }
6 unauthorized: function unauthorized(req) { 7 return { 8 janus: 'error', 9 transaction: req.transaction, 10 error: { 11 code: 403, 12 reason: 'Unauthorized request (wrong or missing secret/token)' 13 } 14 }; 15 }
15 function unauthorized(res) { 16 res.set('WWW-Authenticate', 'Basic realm=Authorization Required'); 17 return res.sendStatus(401); 18 };