New Users should be able to sign up with Email and Password
Requirements
[ ] 1. API should accept following parameters as POST body in JSON format.
NOTE Api should be public and not required any auth headers
create a function named signup in user.service.ts
[ ] Note that, AES_ENCRYPTED_KEY must be stored in a separate mongo collection called verification along with user reference to fetch it later.
[ ] AES_ENCRYPTED_KEY should be created using random characters and a SALT from the.env
example of verification document:
{
"blacklisted": false, // will be used later if we need to blacklist a key
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1ZTZiNGZlOTc2NmE3YTFmMjgxZWQzYjIiLCJpYXQiOjE1ODQwOTExMjcsImV4cCI6MTU4NjY4MzEyN30.YVo52NeI-Aju02ENTUOg6ch5En_94i2G8rA7x1WjNDY", // AES_ENCRYPTED_KEY
"email": "user@email.com", // User's Email
"createdAt": "2020-03-13T09:18:47.247Z",
"updatedAt":"2020-03-13T09:18:47.247Z",
"__v": 0
}
[ ] 3. Add another field in user.model.ts to save status if user has verified his email address.
[ ] 4. Save User in user collection with isVerified :false, role: config.roles[0] i.e. user
Email Verification API
[ ] 5. Once user clicks the link, We need to check if the token value in the URL query string EXISTS in the collection verification. This should be done via a service in auth.service.ts. In case it doesn't exists, it should throw an error with 404 HTTP status.
[ ] 6. If its valid AES_ENCRYPTED_KEY, and exists in the database, proceed next task,
[ ] 7. Now we have verification document in our hands. Now simply fetch user from the user model and update isVerified:true and delete the verification document and respond with 200 HTTP status.
At this stage we should have a new user successfully signed up.
New Users should be able to sign up with Email and Password
Requirements
[ ] 1. API should accept following parameters as POST body in JSON format. NOTE Api should be public and not required any auth headers create a function named
signup
inuser.service.ts
[ ] 2. Once user requests above api, it should :
[ ] Validate all the parameters correctly
[ ] Send Email with sendgrid to user containing an email verification link in following format:
AES_ENCRYPTED_KEY
must be stored in a separate mongo collection calledverification
along with user reference to fetch it later.AES_ENCRYPTED_KEY
should be created using random characters and aSALT
from the.env
example of
verification
document:[ ] 3. Add another field in
user.model.ts
to save status if user has verified his email address.[ ] 4. Save User in
user
collection withisVerified :false, role: config.roles[0]
i.e. userEmail Verification API
[ ] 5. Once user clicks the link, We need to check if the
token
value in the URL query string EXISTS in the collectionverification
. This should be done via a service inauth.service.ts
. In case it doesn't exists, it should throw an error with 404 HTTP status.[ ] 6. If its valid
AES_ENCRYPTED_KEY
, and exists in the database, proceed next task,[ ] 7. Now we have
verification
document in our hands. Now simply fetch user from theuser
model and updateisVerified:true
and delete theverification
document and respond with 200 HTTP status.At this stage we should have a new user successfully signed up.