Skip to content

Commit

Permalink
feat: add getRequest method int IAuthGuard interface
Browse files Browse the repository at this point in the history
  • Loading branch information
ferjul17 committed Feb 10, 2021
1 parent 1b180ef commit d2ac367
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/auth.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@ export type IAuthGuard = CanActivate & {
): Promise<void>;
handleRequest<TUser = any>(err, user, info, context, status?): TUser;
getAuthenticateOptions(context): IAuthModuleOptions | undefined;
getRequest<T = any>(context: ExecutionContext): T;
};
export const AuthGuard: (
type?: string | string[]
) => Type<IAuthGuard> = memoize(createAuthGuard);

const NO_STRATEGY_ERROR = `In order to use "defaultStrategy", please, ensure to import PassportModule in each place where AuthGuard() is being used. Otherwise, passport won't work correctly.`;

function createAuthGuard(type?: string | string[]): Type<CanActivate> {
class MixinAuthGuard<TUser = any> implements CanActivate {
function createAuthGuard(type?: string | string[]): Type<IAuthGuard> {
class MixinAuthGuard<TUser = any> implements IAuthGuard {
constructor(@Optional() protected readonly options?: AuthModuleOptions) {
this.options = this.options || {};
if (!type && !this.options.defaultStrategy) {
Expand Down

0 comments on commit d2ac367

Please sign in to comment.