Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
process.emitWarning(
`Invalid state from /auth-callback request! Expected '${request.session!.state}' and got '${request.query.state}'.`,
);
return SSORouter.sendResponse(response, httpStatus.BAD_REQUEST, 'InvalidState');
}
delete request.session!.state;
const authResponse = await SSORouter.doAuthRequest(SSORouter.getSSOAuthString(), request.query.code);
if (!authResponse || authResponse.status !== httpStatus.OK) {
return SSORouter.sendResponse(response, httpStatus.BAD_GATEWAY, 'SSOTokenResponseError');
}
const token = jwt.decode(authResponse.data.access_token) as IJWTToken;
if (!SSORouter.isJWTValid(token)) {
return SSORouter.sendResponse(response, httpStatus.BAD_GATEWAY, 'InvalidJWTToken');
}
const {characterID, characterName, characterOwnerHash, characterScopes} = SSORouter.extractJWTValues(token);
let user = await User.getFromId(request.session!.user.id);
if (!user) {
return SSORouter.sendResponse(response, httpStatus.NOT_FOUND, 'UserNotFound');
}
let character = await Character.getFromId(characterID);
// Only revoke the token if the new one is different.
if (character && character.refreshToken && character.refreshToken !== authResponse.data.refresh_token) {
// Revoke old token
SSORouter.revokeKey(character.refreshToken, 'refresh_token').then();
it('fail if an unexpected error code is received without an error', function (done) {
var cp = new cmdPoll(afterProvisionValidParamsWithTDE);
var tdeResult = {
statusCode:HttpStatus.BAD_GATEWAY,
body:{
message:'Bad Gateway'
}
};
msRestRequest.PUT.withArgs('https://management.azure.com//subscriptions/55555555-4444-3333-2222-111111111111/resourceGroups/sqldbResourceGroup/providers/Microsoft.Sql/servers/golive4/databases/sqldb/transparentDataEncryption/current')
.yields(null, tdeResult, tdeResult.body);
cp.poll(sqldbOps, function (err, result) {
should.exist(err);
err.message.should.equal('Bad Gateway');
done();
});
});
if (_.get(error, 'body.params.err') === 'USER_NOT_FOUND') {
reject(this.customError({
message: 'User not found!',
status: HttpStatus.NOT_FOUND,
isCustom:true
}))
} else if (_.get(error, 'body.params.err') === 'UNAUTHORIZE_USER') {
reject(this.customError({
message: 'Unauthorized User!',
status: HttpStatus.UNAUTHORIZED,
isCustom:true
}))
} else {
reject(this.customError({
message: 'Unknown Error!',
status: HttpStatus.BAD_GATEWAY,
isCustom:true
}))
}
})
} catch (error) {
options.pgtFn.call(null, pgtIou, function(err, pgt){
if (err) return res.send(HttpStatus.BAD_GATEWAY);
req.session.pgt = pgt;
next();
});
return;
proxy.on('error', function (error) {
arguments[0].status = httpStatus.BAD_GATEWAY;
mole.logger.error('Error in HTTP proxy: %s', error.stack);
mole.statsd.increment('proxy_response_' + arguments[0].status);
mole.statsd.increment('proxy_error');
handleError.apply(null, arguments);
});
return proxy;
export function badGateway(arg1: T | string | Wrapper, arg2?: string): T {
return answer(HTTP.BAD_GATEWAY, arg1, arg2);
}