Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async googleCallback(
@param.query.string('code') code: string,
@param.query.string('state') state: string,
@inject(RestBindings.Http.RESPONSE) response: Response,
): Promise {
const clientId = new URLSearchParams(state).get('client_id');
if (!clientId || !this.user) {
throw new HttpErrors.Unauthorized(AuthErrorKeys.ClientInvalid);
}
const client = await this.authClientRepository.findOne({
where: {
clientId: clientId,
},
});
if (!client || !client.redirectUrl) {
throw new HttpErrors.Unauthorized(AuthErrorKeys.ClientInvalid);
}
try {
const codePayload: ClientAuthCode = {
clientId,
user: this.user,
};
const token = jwt.sign(codePayload, client.secret, {
expiresIn: client.authCodeExpiration,