Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/adhithya christen/firebase auth, sign up routes #40

Merged
merged 23 commits into from
Feb 16, 2023

Conversation

christen03
Copy link
Contributor

@christen03 christen03 commented Feb 11, 2023

Tracking Info

Resolves #27

Make sure your branch name conforms to: <feature|staging|bugfix|...>/<username>/<3-4 word description separated by dashes>. Otherwise, please rename your branch and create a new PR.

Changes

We implemented POST routes for both mentee and mentor with error handling. We also connected our routes to Firebase, so for every user created, Firebase will also store their data along with a personal access token.

Testing

We ran test requests to Postman and checked to ensure the data was actually being posted on MongoDB, which it was.

Confirmation of Change

Validation functions for routes can be found in the middleware folder validation.ts
Error handling changes can be found in the errors folder, errors.ts, validationError.ts.
Firebase connections can be found in the services folder, auth.ts, firebase.ts
Routes can be found in the routes folder, routes.ts
Updated mentee/mentor document models can be found in models, mentee.ts, mentor.ts

Copy link
Member

@adhi0331 adhi0331 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The route works for me properly. The error checking messages and mentor/mentee schema will need to be updated, but the route is good to be used for developing the sign-up flow on front-end.

* Have to do this workaround since lint doesn't let
* us export vars
*/
const port = portV;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to add this thing to work around the linting error. Not an important issue right now but if there is a better workaround this, that would be nice because it is a bit messy.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha! Note to resolve this in the clean backend setup task we will make

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#47

build(attr: MentorInterface): MentorDoc;
}

const mentorSchema = new mongoose.Schema({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After looking at Figma I realize that we need to update mentor and mentee schema to store additional values (images, major, interests, etc.). Not important now but it will be updated in future PR's.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is kinda important so that the the frontend can be properly integrated with the Signup flow. Since this shouldn't take too long, can we add the fields?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be resolved - #46

Copy link
Contributor

@HarshGurnani HarshGurnani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good to me, there still seems to be lint errors in user.ts but if those console messages are supposed to be present then everything is good!

Copy link
Collaborator

@AmanKAggarwal AmanKAggarwal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work setting up all the auth stuff! Left some comments on finishing up the sign-up route but other than that looks good. Please ping on slack when you address the changes so that I can approve

@@ -68,6 +68,7 @@
);
path = ALUM;
sourceTree = "<group>";
usesTabs = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this?

let serviceAccountKeyV = "";

/**
* Todo: these should throw errors instead of logging messages
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noting to make an issue for this task

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#47

* Have to do this workaround since lint doesn't let
* us export vars
*/
const port = portV;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha! Note to resolve this in the clean backend setup task we will make

* This class is used to contain any error messages pertaining
* to validating inputs.
*/
const INVALID_EMAIL_ID = "Invalid email was found, email must not have @iusd.org.";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An issue I faced with this approach in LAKTAA was that as we developed more, we had a lot of error messages so maintaining all of them like this became a pain. Maybe something to note for future

backend/src/middleware/validation.ts Show resolved Hide resolved
@@ -1,19 +1,19 @@
import express, { Request, Response } from "express";
import { User } from "../models/users";
// import express, { Request, Response } from "express";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will we need this commented out code in future?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so right, we don't need this anymore

*
* Mentee: {type: string, name: string, email: string,password: string}
*/
router.post(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

There are several fields still pending from the figma. This route will be called when the submit button is pressed and it will send all the data collected in the sign-up flow to here. Can you add those fields to the route and model?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add grade, topics of interest, career interests, and what do you hope question

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#46

build(attr: MentorInterface): MentorDoc;
}

const mentorSchema = new mongoose.Schema({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is kinda important so that the the frontend can be properly integrated with the Signup flow. Since this shouldn't take too long, can we add the fields?

backend/src/routes/user.ts Show resolved Hide resolved
@@ -0,0 +1,31 @@
/**
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!! Creating a service for auth and firebase is a great idea. These organizational things might seem not important right now but as our codebase increases in size, its usefulness will become clearer.

Copy link
Collaborator

@AmanKAggarwal AmanKAggarwal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Let's merge this PR. There are some tasks pending on the mentor/mentee sign-up that we need to resolve as backlog. Can you make 1 task to resolve all this?

  • Add email regex check for mentor as well
  • See if logic can be reused between mentor and mentee routes
  • Add fields from figma so that Sign-Up Flow is done on backend

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create Sign-up route
4 participants