diff --git a/packages/hoppscotch-backend/.gitignore b/packages/hoppscotch-backend/.gitignore
index 22f55adc5..4a0f78da3 100644
--- a/packages/hoppscotch-backend/.gitignore
+++ b/packages/hoppscotch-backend/.gitignore
@@ -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
\ No newline at end of file
+!.vscode/extensions.json
diff --git a/packages/hoppscotch-backend/Dockerfile b/packages/hoppscotch-backend/Dockerfile
index ab0c88f42..5ee847e55 100644
--- a/packages/hoppscotch-backend/Dockerfile
+++ b/packages/hoppscotch-backend/Dockerfile
@@ -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"]
diff --git a/packages/hoppscotch-backend/package.json b/packages/hoppscotch-backend/package.json
index 940860774..e6e8a0c55 100644
--- a/packages/hoppscotch-backend/package.json
+++ b/packages/hoppscotch-backend/package.json
@@ -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",
diff --git a/packages/hoppscotch-backend/src/guards/gql-auth.guard.ts b/packages/hoppscotch-backend/src/guards/gql-auth.guard.ts
index aabc77b10..bd566c4ba 100644
--- a/packages/hoppscotch-backend/src/guards/gql-auth.guard.ts
+++ b/packages/hoppscotch-backend/src/guards/gql-auth.guard.ts
@@ -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',
};
diff --git a/packages/hoppscotch-backend/src/user/user.model.ts b/packages/hoppscotch-backend/src/user/user.model.ts
index 779dbc4db..5f1fe640f 100644
--- a/packages/hoppscotch-backend/src/user/user.model.ts
+++ b/packages/hoppscotch-backend/src/user/user.model.ts
@@ -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;
}
diff --git a/packages/hoppscotch-backend/src/user/user.module.ts b/packages/hoppscotch-backend/src/user/user.module.ts
index 3681faad5..bdf5d79e5 100644
--- a/packages/hoppscotch-backend/src/user/user.module.ts
+++ b/packages/hoppscotch-backend/src/user/user.module.ts
@@ -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 {}
diff --git a/packages/hoppscotch-backend/src/utils.ts b/packages/hoppscotch-backend/src/utils.ts
index a4756f5e6..fbd9069b3 100644
--- a/packages/hoppscotch-backend/src/utils.ts
+++ b/packages/hoppscotch-backend/src/utils.ts
@@ -108,3 +108,14 @@ export const taskEitherValidateArraySeq = (
TE.getApplicativeTaskValidation(T.ApplicativeSeq, A.getMonoid()),
),
);
+
+/**
+ * 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);
+};
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index b65ffb72c..b9228343c 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -66,6 +66,7 @@ importers:
apollo-server-express: ^3.11.1
apollo-server-plugin-base: ^3.7.1
argon2: ^0.30.3
+ bcrypt: ^5.1.0
eslint: ^8.29.0
eslint-config-prettier: ^8.5.0
eslint-plugin-prettier: ^4.2.1
@@ -79,6 +80,7 @@ importers:
ioredis: ^5.2.4
jest: ^29.3.1
jest-mock-extended: ^3.0.1
+ luxon: ^3.2.1
passport: ^0.6.0
passport-jwt: ^4.0.1
postmark: ^3.0.15
@@ -106,6 +108,7 @@ importers:
apollo-server-express: 3.11.1_4mq2c443wwzwcb6dpxnwkfvrzm
apollo-server-plugin-base: 3.7.1_graphql@15.8.0
argon2: 0.30.3
+ bcrypt: 5.1.0
express: 4.18.2
fp-ts: 2.13.1
graphql: 15.8.0
@@ -114,6 +117,7 @@ importers:
graphql-subscriptions: 2.0.0_graphql@15.8.0
io-ts: 2.2.16_fp-ts@2.13.1
ioredis: 5.2.4
+ luxon: 3.2.1
passport: 0.6.0
passport-jwt: 4.0.1
postmark: 3.0.15
@@ -7225,6 +7229,18 @@ packages:
safe-buffer: 5.1.2
dev: true
+ /bcrypt/5.1.0:
+ resolution: {integrity: sha512-RHBS7HI5N5tEnGTmtR/pppX0mmDSBpQ4aCBsj7CEQfYXDcO74A8sIBYcJMuCsis2E81zDxeENYhv66oZwLiA+Q==}
+ engines: {node: '>= 10.0.0'}
+ requiresBuild: true
+ dependencies:
+ '@mapbox/node-pre-gyp': 1.0.10
+ node-addon-api: 5.0.0
+ transitivePeerDependencies:
+ - encoding
+ - supports-color
+ dev: false
+
/binary-extensions/2.2.0:
resolution: {integrity: sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==}
engines: {node: '>=8'}
@@ -12622,6 +12638,11 @@ packages:
engines: {node: '>=12'}
dev: false
+ /luxon/3.2.1:
+ resolution: {integrity: sha512-QrwPArQCNLAKGO/C+ZIilgIuDnEnKx5QYODdDtbFaxzsbZcc/a7WFq7MhsVYgRlwawLtvOUESTlfJ+hc/USqPg==}
+ engines: {node: '>=12'}
+ dev: false
+
/macos-release/2.5.0:
resolution: {integrity: sha512-EIgv+QZ9r+814gjJj0Bt5vSLJLzswGmSUbUpbi9AIr/fsN2IWFBl2NucV9PAiek+U1STK468tEkxmVYUtuAN3g==}
engines: {node: '>=6'}