Рет қаралды 28
process:
1.--Import Required Modules.
2.--Initialize Express and Firebase
Initialize App and Firebase:
Create an Express app instance.
Load Firebase credentials and initialize Firebase admin with those credentials.
Initialize Firestore database instance.
3.--Set the port number.
Configure EJS as the view engine and set the views directory.
Use body-parser to parse URL-encoded bodies.
Serve static files from the 'public' directory.
4.--defining a login route.
5.--Retrieve email and password from the request body.
Check if a user with the provided email exists in Firestore.
If the user exists, compare the provided password with the stored hashed password
using bcrypt.
If the password matches, redirect to /main.html; otherwise, send an error message.
6.--defining a signup route.
7.--Retrieve email and password from the request body.
Check if a user with the provided email already exists in Firestore.
If the user does not exist, hash the password using bcrypt and save the new user document in Firestore.
After successfully creating the user, redirect to the login page.
8.--Start the Express server and have it listen on the specified port.