feat: magic-link auth complete

This commit is contained in:
Balu Babu
2023-01-10 16:06:42 +05:30
parent 0c154be04e
commit fc284fd0a2
17 changed files with 6590 additions and 65 deletions

View File

@@ -1,17 +1,9 @@
import { createParamDecorator, ExecutionContext } from '@nestjs/common';
import { User } from '../user/user.model';
import { GqlExecutionContext } from '@nestjs/graphql';
export const GqlUser = createParamDecorator<any, any, User>(
(_data: any, context: ExecutionContext) => {
const { user } = GqlExecutionContext.create(context).getContext<{
user: User;
}>();
if (!user)
throw new Error(
'@GqlUser decorator use with null user. Make sure the resolve has the @GqlAuthGuard present.',
);
return user;
export const GqlUser = createParamDecorator(
(data: unknown, context: ExecutionContext) => {
const ctx = GqlExecutionContext.create(context);
return ctx.getContext().req.user;
},
);