PLEASE HELP at around 54:10 there's an error on the console for me: POST localhost:3000/api/register 404 (Not Found) the request payload on the Network did ate the values but the response one only returned a 404 The same error also applies on ur alternative code dat u gave on ur description Am I missing something? Please help cuz I'm losing hairs trying to figure out the bug
Error: ENOENT: no such file or directory, stat 'C:\Users a\Desktop\sql_user_page\public egister.html' - I keep on getting this error, anytime I try to click on either the register page or the Login Page
Hey, im getting constantly this error when clicking the register button: "Failed to load resource: net::ERR_CONNECTION_REFUSED" and "Uncaught (in promise) TypeError: Failed to fetch at HTMLFormElement. (register.js:6:5)" What am I doing wrong?
@@Elderny const jwt = require("jsonwebtoken"); const db = require("../routes/db-config"); const bcrypt = require("bcryptjs"); const login = async (req, res) => { const { id, psword } = req.body; if (!id || !psword) return res.json({ status: "error", error: "아이디나 비밀번호를 입력해주세요" }); else { db.query('SELECT * FROM users01 WHERE id = ?', [id], async (Err, result) => { if (Err) throw Err; if ( !result.length || !await bcrypt.compare(psword, result[0].psword)) return res.json({ status: "error", error: "아이디나 비밀번호를 확인해주세요"}) else { const token = jwt.sign({ id: result[0].id}, process.env.JWT_SECRET, { expiresIn: process.env.JWT_EXPIRES }) const cookieOptions = { expiresIn: new Date(Date.now() + process.env.COOKIE_EXPIRS * 24 * 60 * 60 * 1000), httpOnly: true } res.cookie("userRegistered", token, cookieOptions); return res.json({status:"success", success:"로그인 되었습니다"}) } }) } } module.exports = login; It is obviously the same code as the video, but even if the ID and password information are entered correctly, it is caught in the second if and does not return success
hello i got this error at 55:47 and i didnt know how to fix it : Failed to load resource: the server responded with a status of 404 (Not Found) can u help me ?
@Elderny hey man could you help me with something? when I try to login i get this error in the terminal : ""httpOnly" is not allowed in "options" on login.js, around line 14. Any idea how to fix it?
Yup, it's simple. Create few extra fields with name refer_code, referred_by Refer code would be every person's unique code, you can make the refer_code to be the I'd of the person itself it's upto you or you can keep random string in it with 6-7 alphabets. And referred_by will contain the refer_code of the user using whose link you joined. So, if you're registering using someone's referral link you'll add his refer_code in the referred_by field and that should be it. For counting how much people someone has referred you can just use the COUNT of SQL and select all users having your refer_code as their referred_by Or you can just create another field named refer_count which initially will be 0 but it'll increase by +1 each time someone's joins using the link (not preferred) as it can mess up *rarely* What I told you is 1 level referral system, you can add multi level referral system too by adding second_referred_by field and populate it accordingly (keep its value NULL by default same for referred_by) as initially your first user won't be referred by anyone cause you'll create it yourself more like first default row
Sir I got error Node_modules\express\lib outer oute.js throw new Error(msg); Route.get() requires a callback function but got a [object Object] Please help me I am getting this error again and again.
You mentioned in the video that you weren't going to go through email validation. Do you know where I can find the source code for this email validation or a video?
Nodemailer with Gmail api This will let you send emails for free And for validation generate a random unique uuid and store it in the database with verification_uuid and make another column with name verified which by default will be false Then create a different page with /verify or something in the url and when you'll send the link to the user add the verification uuid in the param like /verify?verify_uuid=uniqueuuid Afterwards, you can just use js to send some api request to your back-end where you are verifying the verification uuid and changing the verified to true wherever that verification uuid was present and you can just remove the verification uuid from the database
Hey man, can I have the latest source code because the github source code is outdated and in the controllers folder only have auth.js only. Thanks for your cooperation
@@Elderny so is there any update regarding this matter ? also I have some confusion with the code because I did not understand the basic of the redirecting to other pages... how can I redirect my login page to my landing page.. please help me... really do appreciate it Thanks :)
@@Elderny Also when im loging i get this error: C:\Users\saitz\Desktop\Panel\app ode_modules\jsonwebtoken\sign.js:107 return failure(new Error('secretOrPrivateKey must have a value')); ^ Error: secretOrPrivateKey must have a value at module.exports [as sign] (C:\Users\saitz\Desktop\Panel\app ode_modules\jsonwebtoken\sign.js:107:20) at Query. (C:\Users\saitz\Desktop\Panel\app\controllers\auth.js:30:35)
Looks like your secret key doesn't have any value check properly if you're providing that value if you're getting it from .env make sure you're using require('dotenv').config() in your main index or app file
I saw that returning like that is not supported so i would say to when listening to the submit event listener do e.prventDefault() provide e as a incoming argument And brother give me full page code this issue should not actually be come and if doesn't cause any issue just ignore the error
I got an error during i register the email and password.... please help me and pls share the source code it will be very beneficial for me. fetch("/api/register",{ method:"POST",
In routes --> pages.js, we have APIs written.. I'm just showing the part where the change is to be made.. {root: "./public"} The route has to be given correctly.. dot and / have to be dealt with carefully. For both register and login. I hope this helps.
@Elderny Hello, I have a question: could you explain why I'm still logged in when I try to use 2nd or 3rd private session on my browser? What should I change to have myself "not-logged in" while using new private windows on a browser? Thank you for this tutorial
Well actually we are saving the cookie in ones browser, and if you try anything you can't let yourself logout if you open some more windows. If this is not your exact question then explain more 🙂
@@Elderny when you were checking the browser to login again you didnt record the browser it stays at the editor while you explaining things until 1:04:13
thanks for creating this video but you didn't share the source code that's the worst part bcz people are facing lot of problems with this code. plz share this source code it'll be more helpful
90% of the viewers are watching to copy the code without understanding it. However, what is the point of waisting your time on something if you’re not gonna explain it? I bet you’re Arabic, no wonder I have switched to English people.
@@Elderny your work is good and your English is perfect. However, I was here to get a syntax of something but I noticed how fast and unclear you was “especially if a beginner is watching”. It could be better to split your work into several videos.
Thanks for that, and yes i already noticed that thing. I wanted to fix the speed but the video was already there. In my future videos I'll try to maintain my speed and proper explanation. Have a nice day :)
code: 'ER_BAD_DB_ERROR', errno: 1049, sqlMessage: "Unknown database 'sql_login'", sqlState: '42000', fatal: true this is what am getting in my node after trying to connect to database i did everything as you did
yes and i have solved the error but i have a new error@@Elderny C:\Users\User\chat_room\index.js:13 db.connect((err)=>{ ^ TypeError: db.connect is not a function at Object. (C:\Users\User\chat_room\index.js:13:4) at Module._compile (node:internal/modules/cjs/loader:1256:14) at Module._extensions..js (node:internal/modules/cjs/loader:1310:10) at Module.load (node:internal/modules/cjs/loader:1119:32) at Module._load (node:internal/modules/cjs/loader:960:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:23:47 Node.js v18.17.0 [nodemon] app crashed - waiting for file changes before starting...
Thanks I have solved the error but am stuck on the 50th minute of the tutorial I try to login but I get this error on the browser uncaught error in promise failed to fetch and the fetch api longin is highlighted@@Elderny
PLEASE HELP
at around 54:10 there's an error on the console for me:
POST localhost:3000/api/register 404 (Not Found)
the request payload on the Network did ate the values but the response one only returned a 404
The same error also applies on ur alternative code dat u gave on ur description
Am I missing something? Please help cuz I'm losing hairs trying to figure out the bug
Kindly upload your code to GitHub and send me link on telegram @elderny1
@@Elderny it's all gud now! the issue was I somehow doubled the router's .use on my main app.js and misplaced it lol thanks anyway~
That was very useful for me, thanks. :)
Error: ENOENT: no such file or directory, stat 'C:\Users
a\Desktop\sql_user_page\public
egister.html'
- I keep on getting this error, anytime I try to click on either the register page or the Login Page
Check if the file is there or not
Hey, im getting constantly this error when clicking the register button:
"Failed to load resource: net::ERR_CONNECTION_REFUSED" and "Uncaught (in promise) TypeError: Failed to fetch
at HTMLFormElement. (register.js:6:5)"
What am I doing wrong?
You fixed it?
At 1:00, even if the ID and password are the same, the solution does not work like the video. Which part should I watch?
Explain Little more
@@Elderny const jwt = require("jsonwebtoken");
const db = require("../routes/db-config");
const bcrypt = require("bcryptjs");
const login = async (req, res) => {
const { id, psword } = req.body;
if (!id || !psword) return res.json({ status: "error", error: "아이디나 비밀번호를 입력해주세요" });
else {
db.query('SELECT * FROM users01 WHERE id = ?', [id], async (Err, result) => {
if (Err) throw Err;
if ( !result.length || !await bcrypt.compare(psword, result[0].psword)) return res.json({ status: "error",
error: "아이디나 비밀번호를 확인해주세요"})
else {
const token = jwt.sign({ id: result[0].id}, process.env.JWT_SECRET, {
expiresIn: process.env.JWT_EXPIRES
})
const cookieOptions = {
expiresIn: new Date(Date.now() + process.env.COOKIE_EXPIRS * 24 * 60 * 60 * 1000),
httpOnly: true
}
res.cookie("userRegistered", token, cookieOptions);
return res.json({status:"success", success:"로그인 되었습니다"})
}
})
}
}
module.exports = login;
It is obviously the same code as the video, but even if the ID and password information are entered correctly, it is caught in the second if and does not return success
Thanks man! you're great🔥
Thank you very much. It is very useful information.
You're welcome 🤗, will make a new version soon and might as well start something good
Hi i'm getting an error "[nodemon] app crashed - waiting for file changes before starting..." would you know how to fix this ?
Check your server main file, and see what made it crash. Upload the code on GitHub and I'll take a look at it too
I'm facing the same error.
Text me on telegram: @elderny1
@@Elderny Thanks so much. It's working now
I the end of the video, could you do a tutorial on how you add the google API for email verification?
The error was because the package.json didn't have "start" in "scripts". It is working now. Thank you 😊
hello i got this error at 55:47 and i didnt know how to fix it : Failed to load resource: the server responded with a status of 404 (Not Found) can u help me ?
Yes, what is the cause of error?
@@Elderny how did u do the logout ?
what did u change d ?
i keep getting the error connot get /api/logout
I didn't used /api/logout for logout. I basically moved the code for logout to routes/pages folder so that i can access logout page on just /logout
Hello,
My login information is not saving but browser showing the pages cookies
@Elderny hey man could you help me with something? when I try to login i get this error in the terminal : ""httpOnly" is not allowed in "options" on login.js, around line 14. Any idea how to fix it?
remove the "httpOnly: true" from that object
I think you might've added httpOnly in wrong options object
Error: Failed to lookup view "register" in views directory "./views" ...I've done everything exactly the same still getting this error...please help
Check file names properly
hi, I'm having an issue going to different pages. can you help me.
Sure tell me more about it
mantap wkwa, very helpfuly
Great Video, thank you for your explanation.
what is your folder icon extension in VScode
does anyone know if this code is out dated or something cuz i cant register users
Great vid! What color theme are you using in vscode?
Thank you so much sir.....
This will help me a lot...
1:22:32 what the Referral Link will do ?
Referral link can be used for inviting your friends and get rewards for it or whatever thing you want to set it as
@@Elderny Can you please elaborate what will be the logic when someone click on the referral link ?
Yup, it's simple. Create few extra fields with name refer_code, referred_by
Refer code would be every person's unique code, you can make the refer_code to be the I'd of the person itself it's upto you or you can keep random string in it with 6-7 alphabets. And referred_by will contain the refer_code of the user using whose link you joined. So, if you're registering using someone's referral link you'll add his refer_code in the referred_by field and that should be it.
For counting how much people someone has referred you can just use the COUNT of SQL and select all users having your refer_code as their referred_by
Or you can just create another field named refer_count which initially will be 0 but it'll increase by +1 each time someone's joins using the link (not preferred) as it can mess up *rarely*
What I told you is 1 level referral system, you can add multi level referral system too by adding second_referred_by field and populate it accordingly (keep its value NULL by default same for referred_by) as initially your first user won't be referred by anyone cause you'll create it yourself more like first default row
@@Elderny thankyou brother i implement all the stuff using MERN and it is working exactly like yours .
Sir I got error
Node_modules\express\lib
outer
oute.js
throw new Error(msg);
Route.get() requires a callback function but got a [object Object]
Please help me I am getting this error again and again.
Show me your code where it's router.get()
@@Elderny sir how can I show you?
Upload on GitHub and send me link
@@Elderny
Sir I have sent you already plz help me to come out of this error because it's very important
@@Elderny
Sir I have sent github link on your telegram also. It is deleting again n again from here
You mentioned in the video that you weren't going to go through email validation. Do you know where I can find the source code for this email validation or a video?
Nodemailer with Gmail api
This will let you send emails for free
And for validation generate a random unique uuid and store it in the database with verification_uuid and make another column with name verified which by default will be false
Then create a different page with /verify or something in the url and when you'll send the link to the user add the verification uuid in the param like /verify?verify_uuid=uniqueuuid
Afterwards, you can just use js to send some api request to your back-end where you are verifying the verification uuid and changing the verified to true wherever that verification uuid was present and you can just remove the verification uuid from the database
great tutorial
Thanks men it was very useful
Back again so login.js is running register.js pls help bro
can you please provide a link to the source code? thanks
You want source code?
@@Elderny yes
Can you please provide us the link of source code . Thank you ;)
Well done! Good job . Thank you for the tutorial
I don't have the source code but I hope you learnt something :)
Login.js is running register.js pls help
Did you use express in this video, I'm going to wtach the fulll video
@elderny Thanx bro you are the best💌🤟
Hey man, can I have the latest source code because the github source code is outdated and in the controllers folder only have auth.js only. Thanks for your cooperation
Sure man I'll update soon
@@Elderny so is there any update regarding this matter ? also I have some confusion with the code because I did not understand the basic of the redirecting to other pages... how can I redirect my login page to my landing page.. please help me... really do appreciate it Thanks :)
Contact me on telegram: @elderny1
Hey do you have a suggestion on how to make this work with mssql?
Aren't we using MySQL?
Thank you. You are real.
I'm planning on making easy to understand and better one soon
@@Elderny Also when im loging i get this error: C:\Users\saitz\Desktop\Panel\app
ode_modules\jsonwebtoken\sign.js:107
return failure(new Error('secretOrPrivateKey must have a value'));
^
Error: secretOrPrivateKey must have a value
at module.exports [as sign] (C:\Users\saitz\Desktop\Panel\app
ode_modules\jsonwebtoken\sign.js:107:20)
at Query. (C:\Users\saitz\Desktop\Panel\app\controllers\auth.js:30:35)
Looks like your secret key doesn't have any value check properly if you're providing that value if you're getting it from .env make sure you're using require('dotenv').config() in your main index or app file
@y so that means that i need to create a .env and add the db connection parameters? and what should they be?
You've two options either directly give the database value or either through variable or using .env
Hi would you be able to do tutorial showing how you added the advance features that you showed in the end?
Sure bro, I'll do that soon! Just let me put it in my schedule
very good
What theme do you use I like it lol!!
sir i got this error for the form in login.html: A 'return' statement can only be used within a function body.
I saw that returning like that is not supported so i would say to when listening to the submit event listener do e.prventDefault()
provide e as a incoming argument
And brother give me full page code this issue should not actually be come and if doesn't cause any issue just ignore the error
@@Elderny thank you
I got an error during i register the email and password.... please help me
and pls share the source code it will be very beneficial for me.
fetch("/api/register",{
method:"POST",
What was the error
Have u fixed the error? Cuz im having the same issue
@@reikishinami174 have you ?
Because profile me put method hei to usko kese handle krege??
Which put method?
I am making profile after login and registration but profile table data is not fetch how I can fetch
You should make profile page
Cannot POST /api/register i have this kind of issue how to fix?
Properly check the router setup, check if router is setup for post request
@@Elderny how can i do that? i'm like a new so please elp me out
@@bikashadhikari6737 the file from where we export the router module check that file
@@Elderny
pages.js:
const express = require("express");
const router = express.Router();
router.get("/", (req, res) => {
res.render("index");
})
router.get("/register", (req, res) => {
res.sendFile("register.html", { root: "./public" });
})
router.get("/login", (req, res) => {
res.sendFile("login.html", { root: "./public" });
})
module.exports = router;
result : register.js:6 POST
localhost:8000/api/register 404 (Not Found)
(anonymous) @ register.js:6
VM322:1 Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0
public/js.reister.js:
form.addEventListener("submit", () => {
const register = {
email: email.value,
password: password.value
}
fetch("/api/register", {
method: "POST",
body: JSON.stringify(register),
headers: {
"Content-Type": "application/json"
}
}).then(res => res.json())
.then(data => {
if (data.status == "error") {
success.style.display = "none"
error.style.display = "block"
error.innertext = data.error
} else {
error.style.display = "none"
success.style.display = "block"
success.innertext = data.success
}
})
})
controllers/regeister.js:
const db = require("../routes/db-config");
const bcrypt = require("bcryptjs");
const register = async(req, res) => {
const { email, password: Npassword } = req.body
if (!email || !Npassword) return res.json({ status: "error", error: "Please enter your email and password" });
else {
console.log(email);
db.query('SELECT email FROM users WHERE email = ?', [email], async(err, result) => {
if (err) throw err;
if (result[0]) return res.json({ status: "error", error: "email has already been regestered" })
else {
const password = bcrypt.hash(Npassword, 8);
console.log(password);
db.query('INSERT INTO users SET ?', { email: email, password: password }, (error, results) => {
if (error) throw error;
return res.json({ status: "success", success: "User has been regestered" })
})
}
})
}
}
module.exports = register;
In routes --> pages.js, we have APIs written.. I'm just showing the part where the change is to be made..
{root: "./public"}
The route has to be given correctly.. dot and / have to be dealt with carefully. For both register and login.
I hope this helps.
hei elderny how to make after we registered we will directed to login page, thanks!
just this js code: window.open('/login','_self')
@@Elderny thanks!
@@Elderny where shoud i put it btw
In the .then response of the fetch api like when you get response back from Register as success you put it inside setTimeout about 3 seconds
@Elderny Hello,
I have a question: could you explain why I'm still logged in when I try to use 2nd or 3rd private session on my browser?
What should I change to have myself "not-logged in" while using new private windows on a browser?
Thank you for this tutorial
Well actually we are saving the cookie in ones browser, and if you try anything you can't let yourself logout if you open some more windows. If this is not your exact question then explain more 🙂
@@Elderny so the cookies are stored throughout the whole browser no matter if its public or additional private session opened?
@@ZajebisteJakPojebane private sessions shouldn't have cookies stored
1:01:19 there is a lag in the video please fix it
Like what
@@Elderny when you were checking the browser to login again you didnt record the browser it stays at the editor while you explaining things until 1:04:13
Awesome video but no forgot password feature. Can you do a video on this @Elderny?
What you want
Sure, it's easy to make forgot password :)
@@Elderny Consider making a video on implementing the forgot feature
El proyecto lo puedo emplear en react
yup, soon making a new video
Hello @
Elderny, how to do redirect after clicking login button to my main page ?
In js write: document.location.replace("/")
@Elderny Can you share your VSCode settings for me like font or theme.
Ok bro, cobalt 2 theme font is cascadia code
Hello. Can you upload all the source codes, I want it for my guide in my projects. Thank you 😊🙏🙏
I'll soon make new video
13:15 I thought my device hanged 😂
Haha 😂
sir, i need the source code for it please....
Ok, i uploaded link
The error you had in login page of undefined, i am having the same error in register page
What can i do?? please help
Cross check the variable
Great Work Bro But Can You Make The Pages More Beautiful With Css
Yes we can
I'm learning node and your video very useful... Can you upload edit profile and verify email video please 🙇🏻♂️🙇🏻♂️🙏🏻🙏🏻
Sure
@@Elderny thank you sir😍😍🤗
@@Elderny i need help.
Tell
@Elderny how to transfer to another page after login
@Elderny hello,
I'm getting undefined value in index.ejs after user has logged in so no email is shown after user logged in
Welcome
Please Login
when i try to console.log (),it show that im getting undefined,how to fix it?
well, properly check for the variable email in the code
@@Elderny in which file?login.js in controller?
thanks for creating this video but you didn't share the source code that's the worst part bcz people are facing lot of problems with this code. plz share this source code it'll be more helpful
Oh, i don't have code available right now brother :(
Your source code for this project is all wrong, please fix it =/
Actually, i lost the original code. I saw i had written some code for login already so i shared available one
thanks you sir
Thanks
1:2:50 this video is stopped
thanks
8:28
90% of the viewers are watching to copy the code without understanding it. However, what is the point of waisting your time on something if you’re not gonna explain it? I bet you’re Arabic, no wonder I have switched to English people.
I did tried to explain it, i didn't wanted to explain total basic things so the video will become few hours long.
@@Elderny your work is good and your English is perfect. However, I was here to get a syntax of something but I noticed how fast and unclear you was “especially if a beginner is watching”. It could be better to split your work into several videos.
Thanks for that, and yes i already noticed that thing. I wanted to fix the speed but the video was already there. In my future videos I'll try to maintain my speed and proper explanation. Have a nice day :)
AMA j profile page continue kro yarr
Bro easy ha profile page, contact me on telegram for guidance
Yes sir, we need the source code
Ok, wait I'll share in some time
@@Elderny thanks sir... Because I followed your video but couldn't get it to the end... Am having issue with the req.user
@@qudusolalekan2505 what is it
26:20
For real dude? Big dislike for this!
After 1.00 your screen is not recorded, and what we should do? Imagine how you work???
Hahaha 🤣
1:07:49
26.20
Too much complicated code😵💫😇
:)
-53:38
1:03:28
wtf
What happened?
code: 'ER_BAD_DB_ERROR',
errno: 1049,
sqlMessage: "Unknown database 'sql_login'",
sqlState: '42000',
fatal: true
this is what am getting in my node after trying to connect to database i did everything as you did
Have you created sql_login database in MySQL phpmyadmin
yes and i have solved the error but i have a new error@@Elderny
C:\Users\User\chat_room\index.js:13
db.connect((err)=>{
^
TypeError: db.connect is not a function
at Object. (C:\Users\User\chat_room\index.js:13:4)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47
Node.js v18.17.0
[nodemon] app crashed - waiting for file changes before starting...
Confirm that db variable is properly defined and does contain some value try console logging and debug where is the issue
Thanks I have solved the error but am stuck on the 50th minute of the tutorial I try to login but I get this error on the browser uncaught error in promise failed to fetch and the fetch api longin is highlighted@@Elderny
Yo, wassup bro, can u gimme a social link, i wanna to talk with you, telegram/discord/whatsapp❤️👍
After that, keep going my dear 🌷🌷
@elderny1 telegram, elderny#7338 discord
@@Elderny thx 🌹🌹, i will contact u soon, have a great time.
db.connect is not a function
Showing this error while running nodemon. What to do?
check if you're exporting db config properly
Please, I keep getting this error " 404 Not Found" and the " fetch ( '/api/register', ..." is highlighted. Can you help me?
You might've not properly setted up the routes
Can you explain it well for me? Which file or files should I check ?
Text me on telegram @elderny1
sir, i need the source code for it please....
I'd love to but i delete all folders that i make in video
In controllers folder in register.js it shows error it says email is not identified
Check all variables properly, and check if you defined email or not. Check if you're sending email in request
I have checked it can't find where is the problem can you check the code for me please 🥺
Ok upload the code somewhere and I'll check
@@Elderny
Thank you so much
drive.google.com/file/d/10dpj33RIMxrTkqk-Lcn7aoSSqkAmZyz9/view?usp=sharing