mirror of https://github.com/ghostfolio/ghostfolio
Browse Source
* Fix internal server error on failed social login by redirecting to login page * Update changelogpull/7640/head
committed by
GitHub
3 changed files with 32 additions and 4 deletions
@ -0,0 +1,21 @@ |
|||||
|
import { Logger, mixin, Type } from '@nestjs/common'; |
||||
|
import { AuthGuard, IAuthGuard } from '@nestjs/passport'; |
||||
|
|
||||
|
export function OAuthCallbackGuard(strategy: string): Type<IAuthGuard> { |
||||
|
class OAuthCallbackGuardMixin extends AuthGuard(strategy) { |
||||
|
private readonly logger = new Logger(OAuthCallbackGuard.name); |
||||
|
|
||||
|
public override handleRequest(error: Error, user: any) { |
||||
|
if (error) { |
||||
|
this.logger.error( |
||||
|
`Authentication with the ${strategy} strategy has failed: ${error.message}` |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
// Do not throw, the callback handler redirects to the login page instead
|
||||
|
return user; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return mixin(OAuthCallbackGuardMixin); |
||||
|
} |
||||
Loading…
Reference in new issue