From 813925fc5008dd81ee0d5a1a8161f74dd41ea9ad Mon Sep 17 00:00:00 2001 From: LOGESH-B Date: Fri, 25 Aug 2023 12:20:42 +0530 Subject: [PATCH] remove/warnings --- docs/ForkClone.md | 10 +++---- src/components/Register/Register.css | 2 +- src/pages/ForgotPassword/ForgotPassword.css | 15 ++++------- src/pages/ForgotPassword/ForgotPassword.jsx | 29 ++++++++++++--------- src/pages/Home/Home.jsx | 6 ++++- src/pages/Login/Login.css | 13 +++------ src/pages/ResetPassword/ResetPassword.jsx | 8 +++++- src/server/controller/userController.js | 21 +++++++-------- src/server/model/tokenModel.js | 28 ++++++++++---------- src/server/package-lock.json | 4 --- src/server/routes/userRoutes.js | 8 +++++- 11 files changed, 74 insertions(+), 70 deletions(-) diff --git a/docs/ForkClone.md b/docs/ForkClone.md index 3854ad9..a25a193 100644 --- a/docs/ForkClone.md +++ b/docs/ForkClone.md @@ -1,6 +1,6 @@ -# Fork and Clone +# Fork and Clone -## Steps to fork the repo: +## Steps to fork the repo: ### Step 1 @@ -10,7 +10,7 @@ Go to the main GitHub page of the repo: ### Step 2 -Once you are on the main GitHub page of the repo, click the Fork button at the top right of the page. +Once you are on the main GitHub page of the repo, click the Fork button at the top right of the page. ![](fork.png) @@ -38,7 +38,7 @@ You will now have a forked version of the original repo that is up to date with ### Step 1 Clone this repo to your local machine using (https://github.com/gbowne1/codebooker.git) - + ### Step 2 Create your feature branch usingĀ git checkout -b my-feature @@ -54,4 +54,4 @@ Push to the branch usingĀ git push origin my-feature; ### Step 5 Create a new [pull request] (SubmitPR.md) -After your Pull Request is merged, can you delete your feature branch. \ No newline at end of file +After your Pull Request is merged, can you delete your feature branch. diff --git a/src/components/Register/Register.css b/src/components/Register/Register.css index f845b84..4eff54f 100644 --- a/src/components/Register/Register.css +++ b/src/components/Register/Register.css @@ -5,4 +5,4 @@ justify-content: center; min-height: 100vh; padding: 16px; -} \ No newline at end of file +} diff --git a/src/pages/ForgotPassword/ForgotPassword.css b/src/pages/ForgotPassword/ForgotPassword.css index a853b55..b23cfad 100644 --- a/src/pages/ForgotPassword/ForgotPassword.css +++ b/src/pages/ForgotPassword/ForgotPassword.css @@ -22,30 +22,25 @@ width: 35%; } - - .MuiInputBase-input { font-family: 'Roboto', 'Open Sans', sans-serif; } - .checkbox-wrapper input { - margin-right: .5rem; + margin-right: 0.5rem; } - - .forgotpassword-button { display: flex; align-items: center; justify-content: center; background-color: #1976d2; color: #fff; - padding: .5rem 1.25rem; + padding: 0.5rem 1.25rem; border: none; font-weight: 500; - font-size: .9rem; - border-radius: .25rem; + font-size: 0.9rem; + border-radius: 0.25rem; cursor: pointer; width: 35%; } @@ -56,4 +51,4 @@ justify-content: space-between; align-items: center; flex-wrap: wrap; -} \ No newline at end of file +} diff --git a/src/pages/ForgotPassword/ForgotPassword.jsx b/src/pages/ForgotPassword/ForgotPassword.jsx index e1c7154..d8a3a11 100644 --- a/src/pages/ForgotPassword/ForgotPassword.jsx +++ b/src/pages/ForgotPassword/ForgotPassword.jsx @@ -22,12 +22,8 @@ const ForgotPassword = () => { console.error(error); } - setLoading(false); - } - - - + }; return (
@@ -39,9 +35,9 @@ const ForgotPassword = () => { Update your password
- - Enter your email address and click SEND EMAIL. - + + Enter your email address and click SEND EMAIL. +
@@ -52,13 +48,22 @@ const ForgotPassword = () => { />
-
- Cancel + Cancel
diff --git a/src/pages/Home/Home.jsx b/src/pages/Home/Home.jsx index 0b1d5a5..71441c3 100644 --- a/src/pages/Home/Home.jsx +++ b/src/pages/Home/Home.jsx @@ -52,7 +52,11 @@ function Home() { const notify = (username) => toast.success('Welcome! ' + username); useEffect(() => { - if (location.state.loggin && localStorage.getItem('user')) { + if ( + location.state && + location.state.loggin && + localStorage.getItem('user') + ) { notify(JSON.parse(localStorage.getItem('user')).username); } }, []); diff --git a/src/pages/Login/Login.css b/src/pages/Login/Login.css index e524692..083fc99 100644 --- a/src/pages/Login/Login.css +++ b/src/pages/Login/Login.css @@ -22,27 +22,22 @@ width: 35%; } - - .MuiInputBase-input { font-family: 'Roboto', 'Open Sans', sans-serif; } - .checkbox-wrapper input { - margin-right: .5rem; + margin-right: 0.5rem; } - - .login-button { background-color: #1976d2; color: #fff; - padding: .5rem 1.25rem; + padding: 0.5rem 1.25rem; border: none; font-weight: 700; font-size: 1.25rem; - border-radius: .25rem; + border-radius: 0.25rem; cursor: pointer; width: 35%; } @@ -53,4 +48,4 @@ justify-content: space-between; align-items: center; flex-wrap: wrap; -} \ No newline at end of file +} diff --git a/src/pages/ResetPassword/ResetPassword.jsx b/src/pages/ResetPassword/ResetPassword.jsx index da2edb8..626c3dd 100644 --- a/src/pages/ResetPassword/ResetPassword.jsx +++ b/src/pages/ResetPassword/ResetPassword.jsx @@ -158,7 +158,13 @@ const ResetPassword = () => { variant='contained' sx={{ mt: 3, mb: 2 }} > - {loading && } + {loading && ( + + )} Reset password diff --git a/src/server/controller/userController.js b/src/server/controller/userController.js index 8160fa6..aa2b03e 100644 --- a/src/server/controller/userController.js +++ b/src/server/controller/userController.js @@ -123,11 +123,11 @@ module.exports.forgotPassword = async (req, res) => { } // delete token if it exist in db - const existingToken = await Token.findOne({userId:existinguser._id}); + const existingToken = await Token.findOne({ userId: existinguser._id }); - if(existingToken){ + if (existingToken) { await existingToken.deleteOne(); - console.log("found"); + console.log('found'); } // Create new reset token @@ -137,21 +137,19 @@ module.exports.forgotPassword = async (req, res) => { { expiresIn: '30m' } //30min ); - // get token expiration time const expiresIn = new Date(Date.now() + 30 * 60 * 1000); // Save token to db - const newToken = new Token({ - userId:existinguser._id, - token:resetToken, - created_on:Date.now(), + const newToken = new Token({ + userId: existinguser._id, + token: resetToken, + created_on: Date.now(), expires_in: expiresIn, }); await newToken.save(); - // URL link const resetLink = `http://localhost:3000/reset-password/${resetToken}`; @@ -202,10 +200,9 @@ module.exports.resetPassword = async (req, res) => { //Find token in DB const userToken = await Token.findOne({ token: token, - expires_in:{$gt:Date.now()} + expires_in: { $gt: Date.now() }, }); - if (!userToken) { return res.status(401).json({ message: 'Token expired or invalid', @@ -213,7 +210,7 @@ module.exports.resetPassword = async (req, res) => { } // Find user with that specific token - const userWithToken = await User.findOne({_id:userToken.userId}); + const userWithToken = await User.findOne({ _id: userToken.userId }); // hash new password const hashPassword = await bcrypt.hash(password, 12); diff --git a/src/server/model/tokenModel.js b/src/server/model/tokenModel.js index a1ce593..d87fb3f 100644 --- a/src/server/model/tokenModel.js +++ b/src/server/model/tokenModel.js @@ -1,27 +1,27 @@ const mongoose = require('mongoose'); const tokenSchema = new mongoose.Schema({ - userId:{ + userId: { type: mongoose.Schema.Types.ObjectId, - required:true, - ref:"User" + required: true, + ref: 'User', }, - token:{ - type:String, - required:true, + token: { + type: String, + required: true, }, - created_on:{ - type:Date, - required: true + created_on: { + type: Date, + required: true, }, - expires_in:{ - type:Date, + expires_in: { + type: Date, required: true, - index: { expires: '1s' } - } + index: { expires: '1s' }, + }, }); const Token = mongoose.model('Token', tokenSchema); -module.exports = Token; \ No newline at end of file +module.exports = Token; diff --git a/src/server/package-lock.json b/src/server/package-lock.json index 0bc578e..fbfd91c 100644 --- a/src/server/package-lock.json +++ b/src/server/package-lock.json @@ -16,13 +16,9 @@ "express": "^4.18.2", "express-session": "^1.17.3", "jsonwebtoken": "^9.0.1", -<<<<<<< HEAD - "mongoose": "^7.4.4", -======= "mongodb": "^5.7.0", "mongoose": "^7.3.4", "nodemailer": "^6.9.4", ->>>>>>> origin/master "passport": "^0.6.0", "passport-local": "^1.0.0", "passport-local-mongoose": "^8.0.0" diff --git a/src/server/routes/userRoutes.js b/src/server/routes/userRoutes.js index 5566c57..251e399 100644 --- a/src/server/routes/userRoutes.js +++ b/src/server/routes/userRoutes.js @@ -1,6 +1,12 @@ const express = require('express'); const router = express.Router(); -const { login, signup, logout, forgotPassword, resetPassword } = require('../controller/userController'); +const { + login, + signup, + logout, + forgotPassword, + resetPassword, +} = require('../controller/userController'); router.post('/login', login); router.post('/logout', logout);