Skip to content

Commit

Permalink
Revert "[CHE 39] Create Registration Page And Routing"
Browse files Browse the repository at this point in the history
  • Loading branch information
brok3turtl3 authored Mar 27, 2024
1 parent 978f44d commit 13ed696
Show file tree
Hide file tree
Showing 11 changed files with 9 additions and 288 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ describe("User Controller Tests", () => {
};
});

//TODO This test needs to be refactored to accomodate new controller code
describe("registerUser function", () => {
xit("should handle user registration", async () => {
it("should handle user registration", async () => {
(User.findOne as jest.Mock).mockResolvedValue(null);
(User.create as jest.Mock).mockResolvedValue({
_id: "someId",
Expand Down Expand Up @@ -67,7 +66,7 @@ describe("User Controller Tests", () => {
});

describe("authUser function", () => {
xit("should handle user authentication", async () => {
it("should handle user authentication", async () => {
(User.findOne as jest.Mock).mockResolvedValue({
_id: "someId",
firstName: "John",
Expand Down Expand Up @@ -98,7 +97,7 @@ describe("User Controller Tests", () => {
});

describe("getUserById function", () => {
xit("should get a user by ID", async () => {
it("should get a user by ID", async () => {
(User.findOne as jest.Mock).mockResolvedValue({
_id: "someId",
firstName: "John",
Expand Down Expand Up @@ -126,7 +125,7 @@ describe("User Controller Tests", () => {
});

describe("deleteUserByEmail function", () => {
xit("should delete a user by email", async () => {
it("should delete a user by email", async () => {
(User.findOneAndRemove as jest.Mock).mockResolvedValue({
_id: "someId",
firstName: "John",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ afterAll(async () => {

describe("User Routes", () => {
describe("POST /api/users/register", () => {
xit("should register a user", async () => {
it("should register a user", async () => {
const mockNewUserData = {
firstName: "John",
lastName: "Doh",
Expand All @@ -40,7 +40,7 @@ describe("User Routes", () => {
});

describe("POST /api/users/login", () => {
xit("should login a user", async () => {
it("should login a user", async () => {
const mockUserData = {
email: "[email protected]",
password: "testpassword",
Expand All @@ -56,7 +56,7 @@ describe("User Routes", () => {
});

describe("GET /api/users/:id", () => {
xit("should get a specific user", async () => {
it("should get a specific user", async () => {
// Create a user first
const newUser = {
firstName: "Test",
Expand All @@ -82,7 +82,7 @@ describe("User Routes", () => {
});

describe("DELETE /api/users/:email", () => {
xit("should delete a specific user by email", async () => {
it("should delete a specific user by email", async () => {
const email = "[email protected]";

const res = await request(app).delete(`/api/users/${email}`);
Expand Down
4 changes: 1 addition & 3 deletions client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ import React from "react";
import { BrowserRouter as Router, Route, Routes } from "react-router-dom";
import LandingPage from "./pages/LandingPage";
import NotFoundPage from "./pages/NotFoundPage/NotFoundPage";
import AuthenticatedApp from "./AuthenticatedApp";
import RegistrationPage from "./pages/RegistrationPage/RegistrationPage";
import AuthenticatedApp from "./AuthenticatedApp"

const App = (): JSX.Element => {
return (
<Router>
<Routes>
<Route path="/" element={<LandingPage />} />
<Route path="/registration/" element={<RegistrationPage />} />
<Route path="/app/*" element={<AuthenticatedApp />} />
<Route path="*" element={<NotFoundPage />} />
</Routes>
Expand Down
144 changes: 0 additions & 144 deletions client/src/pages/RegistrationPage/RegistrationPage.tsx

This file was deleted.

33 changes: 0 additions & 33 deletions dev-tools/scripts/alumniDatabaseSeeder.ts

This file was deleted.

18 changes: 0 additions & 18 deletions server/controllers/devControllers.ts

This file was deleted.

18 changes: 0 additions & 18 deletions server/controllers/userController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import User from "../models/userModel";
import generateToken from "../utils/generateToken";
import { Request, Response, NextFunction } from "express";
import { UserType } from "../types/user";
import GraduateInvitation from "../models/graduateInvitationModel";

// ENDPOINT POST api/users/register
// PURPOSE Register a new user
Expand All @@ -13,27 +12,12 @@ const registerUser = async (
next: NextFunction
) => {
const { firstName, lastName, email, password } = req.body;
const { token } = req.query;

try {
const isValidEmail = email.match(/[\w\d\.]+@[a-z]+\.[\w]+$/gim);
if (!isValidEmail) {
return res.status(400).json("Invalid Email");
}

const invitation = await GraduateInvitation.findOne({
email,
token,
tokenExpiry: { $gt: new Date() },
isRegistered: false,
});

//TODO Needs better error handling - this can trigger with situaions other than bad or missing token
if (!invitation) {
return res
.status(400)
.json({ message: "Invalid or expired registration token" });
}
const userExists: UserType | null = await User.findOne({ email });
if (userExists) {
return res.status(400).json({ message: "User already exists!" });
Expand All @@ -46,8 +30,6 @@ const registerUser = async (
});

if (user) {
invitation.isRegistered = true;
await invitation?.save();
res.locals.user = {
_id: user._id,
firstName: user.firstName,
Expand Down
2 changes: 0 additions & 2 deletions server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import path from "path";
import express, { Request, Response, Application, NextFunction } from "express";
import userRoutes from "./routes/userRoutes";
import profileRoutes from "./routes/profileRoutes";
import devRoutes from "./routes/devRoutes";
import connectDB from "./config/db";
import dotenv from "dotenv";
import { notFound, errorHandler } from "./controllers/errorControllers";
Expand All @@ -17,7 +16,6 @@ connectDB();

app.use("/api/users", userRoutes);
app.use("/api/profiles", profileRoutes);
app.use("/api/devRoutes", devRoutes);

console.log(`ENV BEFORE CHECK: ${process.env.NODE_ENV}`);

Expand Down
40 changes: 0 additions & 40 deletions server/models/graduateInvitationModel.ts

This file was deleted.

Loading

0 comments on commit 13ed696

Please sign in to comment.