chore: created the route to initate magic link auth
This commit is contained in:
5
packages/hoppscotch-backend/.gitignore
vendored
5
packages/hoppscotch-backend/.gitignore
vendored
@@ -2,6 +2,9 @@
|
||||
/dist
|
||||
/node_modules
|
||||
|
||||
.env
|
||||
|
||||
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
@@ -32,4 +35,4 @@ lerna-debug.log*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
!.vscode/extensions.json
|
||||
|
||||
@@ -20,4 +20,4 @@ ENV APP_PORT=${PORT}
|
||||
ENV DB_URL=${DATABASE_URL}
|
||||
ENV PRODUCTION=true
|
||||
|
||||
CMD ["pnpm", "run", "start"]
|
||||
CMD ["pnpm", "run", "start:dev"]
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
"apollo-server-express": "^3.11.1",
|
||||
"apollo-server-plugin-base": "^3.7.1",
|
||||
"argon2": "^0.30.3",
|
||||
"bcrypt": "^5.1.0",
|
||||
"express": "^4.17.1",
|
||||
"fp-ts": "^2.13.1",
|
||||
"graphql": "^15.5.0",
|
||||
@@ -40,6 +41,7 @@
|
||||
"graphql-subscriptions": "^2.0.0",
|
||||
"io-ts": "^2.2.16",
|
||||
"ioredis": "^5.2.4",
|
||||
"luxon": "^3.2.1",
|
||||
"passport": "^0.6.0",
|
||||
"passport-jwt": "^4.0.1",
|
||||
"postmark": "^3.0.15",
|
||||
|
||||
@@ -23,9 +23,9 @@ export class GqlAuthGuard implements CanActivate {
|
||||
const idToken = ctx.reqHeaders.authorization.split(' ')[1];
|
||||
|
||||
const authUser: User = {
|
||||
uid: 'aabb22ccdd',
|
||||
displayName: 'exampleUser',
|
||||
photoURL: 'http://example.com/avatar',
|
||||
id: 'aabb22ccdd',
|
||||
name: 'exampleUser',
|
||||
image: 'http://example.com/avatar',
|
||||
email: 'me@example.com',
|
||||
};
|
||||
|
||||
|
||||
@@ -3,25 +3,37 @@ import { ObjectType, ID, Field } from '@nestjs/graphql';
|
||||
@ObjectType()
|
||||
export class User {
|
||||
@Field(() => ID, {
|
||||
description: 'Firebase UID of the user',
|
||||
description: 'ID of the user',
|
||||
})
|
||||
uid: string;
|
||||
id: string;
|
||||
|
||||
@Field({
|
||||
nullable: true,
|
||||
description: 'Displayed name of the user (if given)',
|
||||
description: 'Name of the user (if fetched)',
|
||||
})
|
||||
displayName?: string;
|
||||
name?: string;
|
||||
|
||||
@Field({
|
||||
nullable: true,
|
||||
description: 'Email of the user (if given)',
|
||||
description: 'Email of the user (if fetched)',
|
||||
})
|
||||
email?: string;
|
||||
|
||||
@Field({
|
||||
nullable: true,
|
||||
description: 'URL to the profile photo of the user (if given)',
|
||||
description: 'URL to the profile photo of the user (if fetched)',
|
||||
})
|
||||
photoURL?: string;
|
||||
image?: string;
|
||||
|
||||
@Field({
|
||||
nullable: true,
|
||||
description: 'Flag to determine if user is an Admin or not',
|
||||
})
|
||||
isAdmin?: string;
|
||||
|
||||
@Field({
|
||||
nullable: true,
|
||||
description: 'Date when the user account was created',
|
||||
})
|
||||
createdOn?: string;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { UserResolver } from './user.resolver';
|
||||
import { PubSubModule } from 'src/pubsub/pubsub.module';
|
||||
import { UserService } from './user.service';
|
||||
|
||||
@Module({
|
||||
imports: [PubSubModule],
|
||||
providers: [UserResolver],
|
||||
exports: [],
|
||||
exports: [UserService],
|
||||
})
|
||||
export class UserModule {}
|
||||
|
||||
@@ -108,3 +108,14 @@ export const taskEitherValidateArraySeq = <A, B>(
|
||||
TE.getApplicativeTaskValidation(T.ApplicativeSeq, A.getMonoid<A>()),
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Checks to see if the email is valid or not
|
||||
* @param email The email
|
||||
* @returns A Boolean depending on the format of the email
|
||||
*/
|
||||
export const validateEmail = (email: string) => {
|
||||
return new RegExp(
|
||||
"([!#-'*+/-9=?A-Z^-~-]+(.[!#-'*+/-9=?A-Z^-~-]+)*|\"([]!#-[^-~ \t]|(\\[\t -~]))+\")@([!#-'*+/-9=?A-Z^-~-]+(.[!#-'*+/-9=?A-Z^-~-]+)*|[[\t -Z^-~]*])",
|
||||
).test(email);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user