=> {
+ evt.preventDefault();
+ setIsLoading(true);
+
+ await fetch('http://localhost:3001/api/users/reset_password', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify(formData),
+ });
+
+ setIsLoading(false);
+ setShowSnackbar(true);
+ setFormData((fData) => ({
+ ...fData,
+ email: '',
+ }));
+ };
+
+ return (
+
+
+
+
+
+ Forgot Your Password?
+
+
+ {showSnackbar ? emailResponse : instructions}
+
+ {showSnackbar ? null : generateForm()}
+
+
+
+ {showSnackbar ?
: null}
+
+ );
+}
+
+export default ForgotPassword;
diff --git a/client/src/features/users/Auth/PasswordInput.tsx b/client/src/features/users/Auth/PasswordInput.tsx
index 1a7880b4..a1179b27 100644
--- a/client/src/features/users/Auth/PasswordInput.tsx
+++ b/client/src/features/users/Auth/PasswordInput.tsx
@@ -12,6 +12,7 @@ import FormHelperText from '@material-ui/core/FormHelperText';
import type { Theme } from '@material-ui/core/styles';
import StyledLink from '../../../assets/sharedComponents/StyledLink';
+import routes from '../../../routes';
const useStyles = makeStyles((theme: Theme) => {
return {
@@ -62,7 +63,7 @@ function PasswordInput({
Password
{/* to prop to be updated to use routes once page is set up */}
- {showForgot && Forgot Password?}
+ {showForgot && Forgot Password?}
{error && {error}}
diff --git a/client/src/routes.tsx b/client/src/routes.tsx
index 1109b77d..3d7c2ca8 100644
--- a/client/src/routes.tsx
+++ b/client/src/routes.tsx
@@ -22,6 +22,7 @@ import OfferFormGoods from './features/action/offers/OfferFormGoods';
import OfferFormSkills from './features/action/offers/OfferFormSkills';
import ContactUs from './features/support/ContactUs';
import Help from './features/support/Help';
+import ForgotPassword from './features/users/Auth/ForgotPassword';
const routes = {
Home: {
@@ -52,6 +53,10 @@ const routes = {
component: PrivacyPolicy,
path: '/privacy-policy',
},
+ ForgotPassword: {
+ component: ForgotPassword,
+ path: '/forgot-password',
+ },
Login: {
component: Login,
path: '/login',
diff --git a/server/src/users/users.controller.ts b/server/src/users/users.controller.ts
index 51b43191..1f7e28a7 100644
--- a/server/src/users/users.controller.ts
+++ b/server/src/users/users.controller.ts
@@ -1,4 +1,16 @@
-import { Controller, Get, Post, Body, Patch, Param, Delete, ParseIntPipe } from '@nestjs/common';
+import {
+ Controller,
+ Get,
+ Post,
+ Body,
+ Patch,
+ Param,
+ Delete,
+ Request,
+ Response,
+ ParseIntPipe,
+} from '@nestjs/common';
+import type { Response as ResponseT } from 'express';
import { UsersService } from './users.service';
import { User } from './entities/user.entity';
import { CreateUserDto } from './dto/create-user.dto';
@@ -17,6 +29,19 @@ export class UsersController {
return user;
}
+ @Post('reset_password')
+ async resetPassword(
+ @Request() req,
+ @Response({ passthrough: true }) response: ResponseT,
+ ): Promise {
+ try {
+ const user = await this.usersService.findByEmail(req.body.email);
+ //TODO send email the user
+ } catch (e) {
+ response.status(200).send();
+ }
+ }
+
@Get(':id')
async findOne(@Param('id', ParseIntPipe) id: number) {
return this.usersService.findOne(id);