N
Novu13mo ago
Ja'w'ad

Can't run login with two factor authentication - blog

I am following the blog by Nevo for creating a registration and login with two factor authentication on react. Link: https://novu.co/blog/creating-a-registration-and-a-login-with-two-factor-authentication-on-react/. I'm relatively new to react and the web dev side of programming. Though the blog started quite well with the react code for the login and the signup page. But once it started creating the authentication work flow, I lost it how the codes were supposed to be edited. Also the github to this blog isn't update with this code. I've a few questions/errors: 1. Is the API calls on port 4000 and not 3000? As seen in code in Login.js
`fetch("http://localhost:4000/api/login",
`fetch("http://localhost:4000/api/login",
? 2. After SignUp, I'm not able to login with my credentials. Is there something wrong with my code? 3. I'm editing the code in Login.js with
pp.post("/api/login", (req, res) => {

//:point_down_tone1: Accepts the user's credentials

const { email, password } = req.body;

//:point_down_tone1: Checks for user(s) with the same email and password

let result = users.filter(

(user) => user.email === email && user.password === password

);


//:point_down_tone1: If no user exists, it returns an error message

if (result.length !== 1) {

return res.json({

error_message: "Incorrect credentials",

});

}

//:point_down_tone1: Returns the username of the user after a successful login

res.json({

message: "Login successfully",

data: {

username: result[0].username,

},

});

});
pp.post("/api/login", (req, res) => {

//:point_down_tone1: Accepts the user's credentials

const { email, password } = req.body;

//:point_down_tone1: Checks for user(s) with the same email and password

let result = users.filter(

(user) => user.email === email && user.password === password

);


//:point_down_tone1: If no user exists, it returns an error message

if (result.length !== 1) {

return res.json({

error_message: "Incorrect credentials",

});

}

//:point_down_tone1: Returns the username of the user after a successful login

res.json({

message: "Login successfully",

data: {

username: result[0].username,

},

});

});
I'm getting an error
ERROR
[eslint]
src\components\Login.js
Line 38:2: 'pp' is not defined no-undef
Line 46:16: 'users' is not defined no-undef

Search for the keywords to learn more about each error.
ERROR
[eslint]
src\components\Login.js
Line 38:2: 'pp' is not defined no-undef
Line 46:16: 'users' is not defined no-undef

Search for the keywords to learn more about each error.
Best would be to look into my repository: https://github.com/syedjawadakhtar/auth-system This is the start of a small project I'm doing and it will of great help.
Creating a registration and a login with two-factor authentication ...
If you have thought about building any dashboard, you probably realize you need to implement authentication.You are probably already familiar with terms like Login and Registration.
GitHub
GitHub - syedjawadakhtar/auth-system
Contribute to syedjawadakhtar/auth-system development by creating an account on GitHub.
No description
No description
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server