|
|
@@ -3,19 +3,26 @@ import { DB_NAME, getDatabaseClient } from '../db-utils'; |
|
|
|
import bcrypt from 'bcrypt'; |
|
|
|
import { generateJWT, SALT_ROUNDS } from './auth'; |
|
|
|
import sendGridMail, { MailDataRequired } from '@sendgrid/mail'; |
|
|
|
import { Category } from '../models/category'; |
|
|
|
import { Shelf } from '..//models/shelf'; |
|
|
|
import { v4 as uuidv4 } from 'uuid'; |
|
|
|
|
|
|
|
const authRoutes = express.Router(); |
|
|
|
|
|
|
|
authRoutes.get('/users/', async (request, response) => { |
|
|
|
response.send("List of users will be displayed"); |
|
|
|
}); |
|
|
|
|
|
|
|
authRoutes.post('/register-applicant/', async (request, response) => { |
|
|
|
const name: string = request.body.name; |
|
|
|
const email: string = request.body.email; |
|
|
|
const password: string = request.body.password; |
|
|
|
const userType: string = 'APPLICANT'; |
|
|
|
const isVerified: boolean = false; |
|
|
|
const categories: Array<Category> = []; |
|
|
|
const uncategorised: Shelf = { |
|
|
|
_id: uuidv4(), |
|
|
|
name: 'Uncategorised', |
|
|
|
description: '', |
|
|
|
viewType: 'PRIVATE', |
|
|
|
isArchived: false, |
|
|
|
addedWords: [] |
|
|
|
} |
|
|
|
|
|
|
|
const userCollection = getDatabaseClient().db(DB_NAME).collection('users'); |
|
|
|
|
|
|
@@ -52,7 +59,8 @@ authRoutes.post('/register-applicant/', async (request, response) => { |
|
|
|
email, |
|
|
|
password: hashedPassword, |
|
|
|
isVerified, |
|
|
|
userType, |
|
|
|
categories, |
|
|
|
uncategorised |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
@@ -112,7 +120,7 @@ authRoutes.post('/request-verification/', async (request, response) => { |
|
|
|
sendGridMail.send(otpMail).then(data=> { |
|
|
|
response.send('Verification OTP sent'); |
|
|
|
return; |
|
|
|
}, (err) => { |
|
|
|
}, () => { |
|
|
|
response.sendStatus(500); |
|
|
|
response.send("SMTP system failure"); |
|
|
|
return; |
|
|
|