mern-socialmedia-zainkeepscode's People
Forkers
deepen77 vonypeto hidding-dev dumitrubrinza sa3akash ivandi1980 youssef-of-web kanedev mongker maro4inter kevingrondin jocelyn10 emmijozzy codesupercharged siriphat0homnan bie71 phamthao2001 julius-gitonga adrianrrhb wisdom-uzo mjlbnu fatimafarjallah nyaga-gitonga hermessecund talha-zubair-mayo kushagraved leogatsby 1-0-1pradev werayootk sebastiansolisfenger albertocervera dev-davidprabu trunganhbi hackerwebstr harsh-chaudhary7 avezqureshi14 kalpana-kumarii soulideth karenyu123 pyfundation tausifaman222 arjunpremash avadhjethva letgobao crypt06545 zoli1212 ranlopez07 extrakyo mahdi13222 revealer409 kartheek2159 mernprojects jolanipekun plom7 supra9 dieptran43 pdk3dragon 0syaizz0 dennys27 mustafayilmazx andwhy10 interstellarkai akashakke riandev isnotsally mannu292001 ramkrishna07 muhammadasim01 anshgoyal1 sometimeq bouabidi ammarzeyad azyzhssin saffy69 vrajpatelll niklaus-mikael thongnvbka machimandru mbeka02 abhishek0020 deepanshurawat01 rudra2198 bonmaklad salmduski2 zebikhan donhuvy elias102 miaohf kazerog tawsif-rahman-shopnil tecnology83666 daief48 pateldenish2908 ferymaleha99 cami-code-23 densovan trinhminhhieu alexandrunegru54 luqmanmatloob khushimarothimern-socialmedia-zainkeepscode's Issues
updateUser failed error from the console
CastError: Cast to ObjectId failed for value "undefined" (type string) at path "_id" for model "Users"
at ObjectId.cast (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\schema\objectid.js:248:11)
at SchemaType.applySetters (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\schematype.js:1202:12)
at SchemaType.castForQuery (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\schematype.js:1613:15)
at cast (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\cast.js:348:32)
at Query.cast (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\query.js:4790:12)
at Query._castConditions (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\query.js:2177:10)
at model.Query._findOneAndUpdate (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\query.js:3209:8)
at model.Query.exec (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\query.js:4321:28)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async updateUser (file:///C:/Users/Lenovo/OneDrive/Desktop/mern-chat-app/server/Controllers/UserController.js:54:20) {
stringValue: '"undefined"',
messageFormat: undefined,
kind: 'ObjectId',
value: 'undefined',
path: '_id',
reason: BSONError: Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer
at new ObjectId (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\bson\lib\bson.cjs:2014:23)
at castObjectId (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\cast\objectid.js:25:12)
at ObjectId.cast (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\schema\objectid.js:246:12)
at SchemaType.applySetters (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\schematype.js:1202:12)
at SchemaType.castForQuery (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\schematype.js:1613:15)
at cast (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\cast.js:348:32)
at Query.cast (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\query.js:4790:12)
at Query._castConditions (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\query.js:2177:10)
at model.Query._findOneAndUpdate (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\query.js:3209:8)
at model.Query.exec (C:\Users\Lenovo\OneDrive\Desktop\mern-chat-app\server\node_modules\mongoose\lib\query.js:4321:28),
valueType: 'string',
model: Model { Users }
}
bcrypt.compare() Shows "data and hash arguments required" while testing the loginUser in Controller
` export const loginUser = async(req,res)=>{
const {username,password} = req.body;
try
{
const user = UserModel.findOne({username:username})
if(user)
{
const validity = await bcrypt.compare(password,user.password)
validity? res.status(200).json(user): res.status(400).json("Wrong Password")
}
else
{
res.status(404).json("User does not exist");
}
}
catch (error)
{
res.status(500).json({message: error.message});
}
}`
This is the loginUser function..
while testing on thunderclient I am getting below error
I tried to check if anything is null because I have seen on on Stack Overflow. When I tried to get req.body.password as response which is passed through the Http request body. it is working but for the user.password which is stored in the database, it is showing the null. so it is where the problem but I cant figure out why it is happening?
Can Anybody Help? Thanks in advance
Uncaught Error: Actions must be plain objects. Use custom middleware for async actions.
Action File
import * as AuthApi from "../api/AuthApi.js"
import { useDispatch } from "react-redux"
const dispatch=useDispatch()
export const logIn=(formData)=>async(dispatch)=>{
dispatch({type:"AUTH_START"})
try {
const data=await AuthApi.logIn(formData)
dispatch({type:"AUTH_SUCCESS",data:data})
} catch (error) {
console.log(error)
dispatch({type:"AUTH_FAILED"})
}
}
export const signUp=(formData)=>async(dispatch)=>{
dispatch({type:"AUTH_START"})
try {
const {data}=await AuthApi.signUp(formData)
dispatch({type:"AUTH_SUCCESS",data:data})
} catch (error) {
console.log(error)
dispatch({type:"AUTH_FAILED"})
}
}
Reducer Files
const authReducer=(state={authData:null,loading:false,error:false},action)=>{
switch (action.type) {
case "AUTH_START":
return {...state,loading:true,error:false}
case "AUTH_SUCCESS":
//also storing the data in local storage
localStorage.setItem("profile",JSON.stringify({...action?.data}))
return {...state,loading:false,authData:action.data}
case "AUTH_FAILED":
return {...state,error:true,loading:false}
default:
return state
}
}
export default authReducer
Auth.jsx
import React from "react"
import "./Auth.css"
import Logo from "../img/logo.png"
import {useDispatch, useSelector} from "react-redux"
import { logIn, signUp } from "../api/AuthApi.js"
export default function Auth(){
const [isSignUp,setSignUp]=React.useState(true)
const [data,setData]=React.useState({firstname:"",lastname:"",password:"",confirmpass:"",username:""})
const [confirmpass,setConfirmPass]=React.useState(true)
const dispatch=useDispatch()
const loading=useSelector((state)=>state.authReducer.loading)
console.log(loading)
const handleChange=(e)=>{
setData({...data,[e.target.name]:e.target.value})
}
const resetForm=()=>{
setConfirmPass(true)
setData({firstname:"",lastname:"",password:"",confirmpass:"",username:""})
}
const handleSubmit=(e)=>{
e.preventDefault()
if(isSignUp){
data.password===data.confirmpass ? dispatch(signUp(data)) : setConfirmPass(false)
}
else {
dispatch(logIn(data))
}
}
const spanStyle={
cursor:"pointer",
textDecoration:"underline",
}
return (
<div className="Auth">
<div className="a-left">
<img src={Logo} alt="logo" />
<div className="webname">
<h1>Mariana Chat</h1>
<h6>Explore the world and meet new people </h6>
</div>
</div>
{/* New div */}
<div className="a-right">
<form className="infoForm authForm" onSubmit={handleSubmit}>
<h3>{isSignUp ? "Sign Up" : "Log In"}</h3>
{
isSignUp && <div>
<input type="text" name="firstname" className="infoInput" placeholder="First Name" onChange={handleChange} value={data.firstname}/>
<input type="text" name="lastname" className="infoInput" placeholder="Last Name" onChange={handleChange} value={data.lastname}/>
</div>
}
<div>
<input type="text" name="username" className="infoInput" placeholder="Username" onChange={handleChange} value={data.username}/>
</div>
<div>
<input type="password" name="password" className="infoInput" placeholder="Password" onChange={handleChange} value={data.password}/>
{isSignUp &&
<input type="password" name="confirmpass" className="infoInput" placeholder="Confirm Password" onChange={handleChange} value={data.confirmpass}/>
}
</div>
<span className="confirmPass">
{confirmpass ? "" : "Password don't match"}
</span>
<div>
<span style={spanStyle} onClick={()=>{setSignUp(prev=>!prev)
resetForm()
}}
>{isSignUp ? "Already have an account . Login" : "Don't have an account , Sign Up"}</span>
</div>
<button className="infoButton" >Sign Up</button>
</form>
</div>
</div>
)
}
Kindly help I am struggling with this from 2 days
Add Post Error
Good afternoon, sorry to bother you, I'm your subscriber and I'm learning from your video on "Full Stack MERN Social Media App Tutorial | React Node.js full Course for Beginners JWT, React Redux" and I had a problem adding posts, I get here such errors are shown in the photo, you can tell what the problem is because ChatGPT does not help me to solve this problem correctly
Timeago.js file
WARNING in ./node_modules/timeago.js/esm/register.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/alphalyte/Documents/serviced/Vibe/client/node_modules/timeago.js/src/register.ts' file: Error: ENOENT: no such file or directory, open '/home/alphalyte/Documents/serviced/Vibe/client/node_modules/timeago.js/src/register.ts'
@ ./node_modules/timeago.js/esm/index.js 7:0-38 8:0-8 9:0-8 12:0-20
@ ./src/components/ChatBox/ChatBox.jsx 11:0-36 185:26-32
@ ./src/pages/Chat/Chat.jsx 7:0-55 140:37-44
@ ./src/App.js 12:0-37 139:45-49
@ ./src/index.js 10:0-24 19:38-41
WARNING in ./node_modules/timeago.js/esm/utils/date.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/alphalyte/Documents/serviced/Vibe/client/node_modules/timeago.js/src/utils/date.ts' file: Error: ENOENT: no such file or directory, open '/home/alphalyte/Documents/serviced/Vibe/client/node_modules/timeago.js/src/utils/date.ts'
@ ./node_modules/timeago.js/esm/format.js 1:0-51 12:12-19 14:9-19
@ ./node_modules/timeago.js/esm/index.js 10:0-34 10:0-34
@ ./src/components/ChatBox/ChatBox.jsx 11:0-36 185:26-32
@ ./src/pages/Chat/Chat.jsx 7:0-55 140:37-44
@ ./src/App.js 12:0-37 139:45-49
@ ./src/index.js 10:0-24 19:38-41
WARNING in ./node_modules/timeago.js/esm/utils/dom.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/alphalyte/Documents/serviced/Vibe/client/node_modules/timeago.js/src/utils/dom.ts' file: Error: ENOENT: no such file or directory, open '/home/alphalyte/Documents/serviced/Vibe/client/node_modules/timeago.js/src/utils/dom.ts'
@ ./node_modules/timeago.js/esm/realtime.js 1:0-71 19:8-18 31:2-12 41:18-28 57:14-30
@ ./node_modules/timeago.js/esm/index.js 11:0-44 11:0-44 11:0-44
@ ./src/components/ChatBox/ChatBox.jsx 11:0-36 185:26-32
@ ./src/pages/Chat/Chat.jsx 7:0-55 140:37-44
@ ./src/App.js 12:0-37 139:45-49
@ ./src/index.js 10:0-24 19:38-41
7 warnings have detailed information that is not shown.
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.
webpack 5.70.0 compiled with 7 warnings in 5013 ms
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.