-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
372 changed files
with
15,616 additions
and
16,560 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
process.env.KAFKAJS_LOG_LEVEL='ERROR' | ||
process.env.KAFKAJS_LOG_LEVEL = "ERROR"; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"trailingComma": "es5", | ||
"tabWidth": 2, | ||
"printWidth": 120, | ||
"semi": true, | ||
"singleQuote": false, | ||
"useTabs": false, | ||
"bracketSpacing": true, | ||
"arrowParens": "avoid", | ||
"endOfLine": "auto" | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,32 @@ | ||
import { ErrorCodes } from "@enum/error-codes.enum"; | ||
import { | ||
ExecutionContext, | ||
Injectable, | ||
Logger, | ||
UnauthorizedException, | ||
} from "@nestjs/common"; | ||
import { ExecutionContext, Injectable, Logger, UnauthorizedException } from "@nestjs/common"; | ||
import { AuthGuard } from "@nestjs/passport"; | ||
import { Request as expressRequest, Response } from "express"; | ||
import { RedirectingException } from "./redirecting-exception"; | ||
|
||
@Injectable() | ||
export class KombitAuthGuard extends AuthGuard("kombit") { | ||
constructor() { | ||
super(); | ||
} | ||
constructor() { | ||
super(); | ||
} | ||
|
||
private readonly logger = new Logger(KombitAuthGuard.name); | ||
private readonly logger = new Logger(KombitAuthGuard.name); | ||
|
||
handleRequest( | ||
err: any, | ||
user: any, | ||
info: any, | ||
context: ExecutionContext, | ||
status: any | ||
) { | ||
if (err || !user) { | ||
const req: expressRequest = context.switchToHttp().getRequest(); | ||
const res: Response = context.switchToHttp().getResponse(); | ||
const redirectTarget = req.cookies["redirect"]; | ||
this.logger.error(`Login with KOMBIT failed, got error: ${err}`, err); | ||
handleRequest(err: any, user: any, info: any, context: ExecutionContext, status: any) { | ||
if (err || !user) { | ||
const req: expressRequest = context.switchToHttp().getRequest(); | ||
const res: Response = context.switchToHttp().getResponse(); | ||
const redirectTarget = req.cookies["redirect"]; | ||
this.logger.error(`Login with KOMBIT failed, got error: ${err}`, err); | ||
|
||
if (redirectTarget) { | ||
const redirectError = | ||
err?.message == ErrorCodes.UserInactive | ||
? ErrorCodes.UserInactive | ||
: ErrorCodes.KOMBITLoginFailed; | ||
throw new RedirectingException( | ||
`${redirectTarget}?error=${redirectError}` | ||
); | ||
} else { | ||
throw new UnauthorizedException(ErrorCodes.MissingRole); | ||
} | ||
} | ||
return user; | ||
if (redirectTarget) { | ||
const redirectError = | ||
err?.message == ErrorCodes.UserInactive ? ErrorCodes.UserInactive : ErrorCodes.KOMBITLoginFailed; | ||
throw new RedirectingException(`${redirectTarget}?error=${redirectError}`); | ||
} else { | ||
throw new UnauthorizedException(ErrorCodes.MissingRole); | ||
} | ||
} | ||
return user; | ||
} | ||
} |
Oops, something went wrong.