Today is 8th Jan, 2021,
Node mail sending.
Manually:
When register, you put data in database,
unique code, and put that unique code as a separate field in database,
after you save the information in database, you send the email with some link
// /api/confirm/email?code=uniquecode
To confirm your email, click the following link:
http://domain/api/confirm/email?code=uniquecode
Flow:
Register, Login, Forgot Password, Logout
Client Side
//http://localhost:3000/register
Register:
username,
email,
password,
confirm password,
name,
gender,
// http://localhost:1337/api/users/register
A. Validate the fields:
if !username give error,
B. check if username exists,
take username and match it in database and if it exists, give error.
check if email exists,
take email, match it in database, and if it exists, give error.
generate uniquecode, and also insert that in db.
C. insert record in the database,
D. send email:
You have successfully registered to our website.
Please click following link to verify your email:
http://localhost:1337/api/users/confirmemail?code=uniquecode
// api/users/confirmemail get,
const code = req.query.code;
match it with database, and if it matches, just update another field in database,
email_verified = true,
give message, that email verified, please login.
// login,
username, and password (text format, ),
match this two with database, and once you get result,
you can check email_verified is there or not, error: please verify the email,
login: session/cookie login, jwt - token, client will save jwt token in cookie,
save the userid and username in cookie, and
if cookie exists then it means user is logged in successfully.
Forgot password:
with normal visible password, send email to user with his password,
if password is encrypted, create a new password and send it to user and update that in database.
postgres, mssql
mysql, mongo, insert, update, delete, query, CRUD
Java application - CRUD - api
Node js application, axios to use that api,
React (logic) - Node Js (logic) - api (axios) Java
React (logic) - Node js (mysql)
Parse
role, user, live query
Today is 5th Jan, 2021
React application to utilize that api which we build yesterday.
Todo Web application, with Node JS Api as a backend,
and we will use axios to call the api.
fetch - it is similar to fetch.
First try to find the error, google the error,
Node JS, - api, or display the data:
api and return the json, React should handle the display part: