Rocket.chat custom login using AWS cognito

Issue:
I’m encountering difficulties integrating custom login using AWS Cognito into Rocket.Chat. Although the login form successfully communicates with AWS Cognito and returns a positive response, Rocket.Chat’s authentication flow doesn’t recognize it.

Context:
I’ve utilized the AWS-identity-js package for this integration, ensuring proper communication with AWS Cognito. However, I need assistance understanding Rocket.Chat’s authentication flow and making the necessary customizations to align it with AWS Cognito.

Questions:

Can someone provide insights into Rocket.Chat’s authentication flow to help troubleshoot the integration with AWS Cognito?

What specific customizations are required within Rocket.Chat to ensure seamless integration with AWS Cognito? Are there any endpoint configurations or adjustments needed?

Additionally, I aim to incorporate identity provider (IDP) buttons available in my AWS Cognito user pool into Rocket.Chat’s login interface. How can I achieve this while maintaining the integration with AWS Cognito?

custom login using AWS cognito

Javascript style.display function behaving weird

document.addEventListener('DOMContentLoaded', function() {//When user clicks add Household Button ("(+)" BUTTON in center )
const addHouseholdBtn = document.getElementById('addHousehold');
const popup_prompt_menu = document.getElementById('add-household-prompt');
const householdForm = document.getElementById('add-household-form');
const addDriverFormBackBtn = document.getElementById('add-driver-cancel-btn');
const addDriverForm = document.getElementById('add-driver-form-form');
const addDriverFormBorder = document.getElementById('add-driver-form');

addDriverForm.style.display = "none";

popup_prompt_menu.style.display = "none";
householdForm.style.display = "none";



addHouseholdBtn.addEventListener('click', (event) => {

    event.stopPropagation(); // Prevent the click event from propagating to the document
    popup_prompt_menu.style.display = popup_prompt_menu.style.display === 'block' ? 'none' : 'block';
    
});

//When User clicks submit button in add-household-prompt

const submitPrompt = document.getElementById('submit-prompt');
const driverCheckBox = document.getElementById('add_driver');
const householdCheckBox = document.getElementById('add_household');
const vehicleCheckBox = document.getElementById('add_vehicle');
const policyCheckBox = document.getElementById('add_policy');
const editHousehold = document.getElementById('edit_household');
const errorMessage = document.getElementById('error-message');



//Submit's the prompt that is displayed when clicking the addhousehold  button
submitPrompt.addEventListener('click', (event) => {
    if (driverCheckBox.checked && householdCheckBox.checked && vehicleCheckBox.checked && policyCheckBox.checked) {
        errorMessage.style.display = 'none';
        popup_prompt_menu.style.display = "none";
        householdForm.style.display = 'block'; // Show the form when all checkboxes are checked

    } else if (!editHousehold.checked) {
        errorMessage.innerText = "Error: Each entry must have driver, household, vehicle and a policy! ";
        errorMessage.style.display = 'block';
        errorMessage.style.color = 'red';

    } else if (editHousehold.checked) {
        errorMessage.style.display = 'none';
        popup_prompt_menu.style.display = "none";
        householdForm.style.display = 'none'; // Hide the form if only editHousehold is checked
    }
});

//Returns back to the prompt from the add household form
const backToPrompt = document.getElementById('back-to-prompt');

backToPrompt.addEventListener('click', (event) => {
    householdForm.style.display = "none";
    popup_prompt_menu.style.display = "block";
})

// For back button when prompt is activated

const backToMain = document.getElementById('back-to-main');
backToMain.addEventListener('click', (event) => {
    householdForm.style.display = "none";
    popup_prompt_menu.style.display = "none";
})




});
@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap');

* {
    margin: 0px;
    padding: 0px;
    font-family: roboto;
}

date-wrapper input[type="date"] {
    /* Optional: Reset default input styles */
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;

    /* Optional: Add any additional styling */
    /* Add padding, border, etc. */
}

.household-info {
    text-align: center;
}


.customer-card {
    padding: 50px;
}

.form-wrapper {
    display: flex;

    padding: 20px;
}

.first-half-customers {
    display: flex;
    justify-content: space-between;

}

.second-half-customers {
    display: flex;
    justify-content: space-between;
}

.main-container {


    margin: 20px;
    background-color: #f0f0f0;
    ;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);




}

.date-wrapper {
    display: flex;
    justify-content: center;
    margin-top: 0px;
}


.left-labels {
    display: flex;
    flex-direction: column;
    margin-right: 20px;
    margin-top: 30px;
    margin-left: 10px;



}

input {
    margin-top: 4.5px;


}

p {
    margin-top: 5px;
    font-size: 16px;
}

label {

    padding-bottom: 2px;
    padding-top: 1.2px;
    font-size: 16px;
    font-weight: bold;
}

.control {
    display: flex;
    align-items: center;
    flex-direction: column;
}

#next {
    margin-top: 150px;
}

#add-household-prompt {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    background-color: white;

}

.pop-up-menu-border {
    padding: 50px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 200px;
    font-size: 15px;



}

#submit-prompt {
    text-align: center;
    background-color: #13AA52;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    color: white;
    padding: 2px;
    border-radius: 10px;
    font-size: 15px;
}

#submit-prompt:hover {

    background-color: #40aa6c;


}

.add-household-form {
    position: absolute;
    top: 47%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    font-size: 18px;
}

.add-household-form-border {
    padding: 40px;

}

.add-household-form-inputs {
    width: 100%;
    border-radius: 10px;
    outline: none;
    border: none;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    font-size: 17px;

}

#submit-form-btn {
    margin-top: 10px;
    width: 100%;
    height: 30px;
    background-color: #13AA52;
    color: white;
    border-radius: 17px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}


#back-to-prompt {
    margin-top: 10px;
    background-color: black;
    color: white;
    width: 100%;
    height: 30px;
    border-radius: 17px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);


}

#back-to-main {
    text-align: center;
    background-color: black;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    color: white;
    padding: 3px;
    border-radius: 10px;
    font-size: 15px;
}

.householdControl-container {
    padding: 10px;
    margin: 20px;
    background-color: #f0f0f0;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);

}

.add-driver-form {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    border-radius: 10px;


}

.add-driver-form-border {

    padding: 20px;

}

.section-d {

    display: flex;
    flex-direction: column;
}

.add-driver-form-labels,
.add-driver-inputs {
    display: inline-block;
}

#add-driver-submit-btn {
    background-color: #13AA52;
    width: 50px;
    margin-left: 50px;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    color: white;
}

#add-driver-cancel-btn {
    display: block;
    background-color: black;
    width: 50px;
    margin-left: 50px;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    color: white;
}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="stylesheets/center.css">
  <link rel="stylesheet"
    href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0" />

  <script src="javascripts/slider-function.js" defer></script>
</head>

<div class="main-container">

  <div class="household-info">
    <h1> Household Information</h1>
    <div class="form-wrapper">
      <div class = 'first-half-customers'>
      <% selectedHouseholdCustomers.slice(0, 5).forEach(customer => { %>
        <%- include('customer-card', { customer: customer }) %>
      <% }); %>
    </div>

      <div class ='second-half-customers'>
      <% selectedHouseholdCustomers.slice(5, 10).forEach(customer => { %>
        <%- include('customer-card', { customer: customer }) %>
      <% }); %>
    </div>

     
   


      <div class="control">
        <span class="material-symbols-outlined" id="addHousehold">add_circle</span>
        <span class="material-symbols-outlined" id="next">arrow_forward_ios</span>
        <span class="material-symbols-outlined" id ="previous">arrow_back_ios</span>
      </div>

    </div>

  </div>
 
</div>








 <div class = "householdControl-container">  <%- include ('householdControl', { SelectedHouseholdData: SelectedHouseholdData }) -%></div>
<script>
  document.addEventListener('DOMContentLoaded', function() {
  const firstHalfCustomers = document.querySelector('.first-half-customers');
  const secondHalfCustomers = document.querySelector('.second-half-customers');

  // Hide the second half of customers initially
  secondHalfCustomers.style.display = 'none';
  

  const nextButton = document.getElementById('next');
  const previousButton = document.getElementById('previous');

  nextButton.addEventListener('click', function() {
    firstHalfCustomers.style.display = 'none';
    secondHalfCustomers.style.display = 'flex';
    secondHalfCustomers.style.justifyContent = 'space-between';
    
  });

  previousButton.addEventListener('click', function() {
    firstHalfCustomers.style.display = 'flex';
    firstHalfCustomers.style.justifyContent = 'space-between';
    secondHalfCustomers.style.display = 'none';
    
  });
});

  
</script>

<div class = "add-driver-form">
  <div class = "add-driver-form-border">
  <form action = "/add-driver" method = "post" id = "add-driver-form-form"> 
    <div class = "section-d">
      <label for = "full_name" class = "add-driver-form-labels">Driver Full Name: </label>
      <input type="text" id="full_name" name="name" class="add-driver-form-inputs">
    </div>
    <div class = "section-d">
      <label for = "dob" class = "add-driver-form-labels"> Driver DOB: </label>
      <input type="date" id="dateOfBirth" name="dateOfBirth" class="add-driver-form-inputs">
    </div>
    <div class = "section-d">
      <label for = "relation" class = "add-driver-form-labels">Driver Realation: </label>
      <select id="relation" name="relation">
        <option value="self">self</option>
        <option value="spouse">spouse</option>
        <option value="child">child</option>
        <option value="parent">parent</option>
        <option value="sibling">sibling</option>
        <option value="other">other</option>
      </select>
    </div>
    <div class = "section-d">
      <label for = "year" class = "add-driver-form-labels"> Vehicle Year: </label>
     <input type = "text" id = "year" class = "add-driver-form-inputs" name = "year">
    </div>
    <div class = "section-d">
      <label for = "make" class = "add-driver-form-labels">Vehicle Make: </label>
     <input type = "text" id = "make" class = "add-driver-form-inputs" name = "make">
    </div>
    <div class = "section-d">
      <label for = "model" class = "add-driver-form-labels">Vehicle Model: </label>
     <input type = "text" id = "model" class = "add-driver-form-inputs" name = "model">
    </div>
    <div class = "section-d">
      <label for = "vin" class = "add-driver-form-labels">Vehicle VIN: </label>
     <input type = "text" id = "vin" class = "add-driver-form-inputs" name = "vin">
    </div>
    <div class = "section-d">
      <label for = "policyNumber" class = "add-driver-form-labels">Policy number: </label>
     <input type = "text" id = "policyNumber" class = "add-driver-form-inputs" name = "policyNumber">
    </div>
    <button type ="submit" id ="add-driver-submit-btn">Submit </button>
    <button type ="button" id ="add-driver-cancel-btn" >Back </button>
    
    
    
  </form>
  </div>
  </div>


<!-- Add Household Prompt menu-->
<div class="pop-up-menu" id="add-household-prompt" enctype="multipart/form-data">
  <div class="pop-up-menu-border" id="add-household-prompt-border">
    <div class="pop-up-menu-section">
      <input type="checkbox" id="add_driver" name="addDriver" class="checkboxs">
      <label for="add_driver" class="labels">Create Driver</label>
    </div>
    <div class="pop-up-menu-section">
      <input type="checkbox" id="add_household" name="addHousehold" class="checkboxs">
      <label for="add_household" class="labels">Create Household</label>
    </div>
    <div class="pop-up-menu-section">
      <input type="checkbox" id="add_vehicle" name="addVehicle" class="checkboxs">
      <label for="add_vehicle" class="labels">Create Vehicle</label>
    </div>
    <div class="pop-up-menu-section">
      <input type="checkbox" id="add_policy" name="addPolicy" class="checkboxs">
      <label for="add_policy" class="labels">Create Policy</label>
    </div>
 
    <div class="pop-up-menu-section">
      <input type="checkbox" id="add_driver" name="add_driver" class="checkboxs">
      <label for="add_driver" class="labels">Add Driver </label>
    </div>
    <div class="pop-up-menu-section">
      <input type="checkbox" id="remove_driver" name="remove_driver" class="checkboxs">
      <label for="add_driver" class="labels">Remove Driver</label>
    </div>
    <buttton type="submit" id="submit-prompt">Submit</buttton>
    <button id="back-to-main">Back </button>
    <p id="error-message">
      <p>

  </div>
</div>

<!-- Add Household Form-->
<div class="add-household-form" id="add-household-form">
  <div class="add-household-form-border">

    <h1> New Household</h1>
    <form action="/add_household" method="post">
      <div class="section">
        <label for="upload_picture" class="add-household-form-labels">Upload Profile Picture</label>
        <input type="file" id="upload_picture" name="upload_picture" class="add-household-form-inputs">
      </div>
      <div class="section">
        <label for="full_name" class="add-household-form-labels">Full Name:</label>
        <input type="text" id="full_name" name="full_name" class="add-household-form-inputs">
      </div>
      <div class="section">
        <label for="date_of_birth" class="add-household-form-labels">Date Of Birth:</label>
        <input type="date" id="date_of_birth" name="date_of_birth" class="add-household-form-inputs">
      </div>
      <div class="section">
        <label for="relation" class="add-household-form-labels">Full Name: </label>
        <select id="relation" name="relation" class="add-household-form-inputs">
          <option value="self">Self</option>
          <option value="spouse">Spouse</option>
          <option value="child">Child</option>
          <option value="parent">Parent</option>
          <option value="sibling">Sibling</option>
          <option value="other">Other</option>
        </select>
      </div>
      <div class="section">
        <label for="year" class="add-household-form-labels">Year:</label>
        <input type="text" id="year" name="year" class="add-household-form-inputs">
      </div>
      <div class="section">
        <label for="make" class="add-household-form-labels">Make:</label>
        <input type="text" id="make" name="make" class="add-household-form-inputs">
      </div>
      <div class="section">
        <label for="model" class="add-household-form-labels">Model:</label>
        <input type="text" id="model" name="model" class="add-household-form-inputs">
      </div>
      <div class="section">
        <label for="vin" class="add-household-form-labels">VIN#: </label>
        <input type="text" id="vin" name="vin" class="add-household-form-inputs">
      </div>
      <div class="section">
        <label for="cell_phone" class="add-household-form-labels">Cell Phone: </label>
        <input type="text" id="cell_phone" name="cell_phone" class="add-household-form-inputs">
      </div>
      <div class="section">
        <label for="address" class="add-household-form-labels">Address: </label>
        <input type="text" id="address" name="address" class="add-household-form-inputs">
      </div>
      <div class="section">
        <label for="work_phone" class="add-household-form-labels">Work Phone: </label>
        <input type="text" id="work_phone" name="work_phone" class="add-household-form-inputs">
      </div>
      <div class="section">
        <label for="city" class="add-household-form-labels">City: </label>
        <input type="text" id="city" name="city" class="add-household-form-inputs">
      </div>
      <div class="section">
        <label for="zip_code" class="add-household-form-labels">Zip Code: </label>
        <input type="text" id="zip_code" name="zip_code" class="add-household-form-inputs">
      </div>
      <div class="section">
        <label for="policy_number" class="add-household-form-labels">Policy Number: </label>
        <input type="text" id="policy_number" name="policy_number" class="add-household-form-inputs">
      </div>
      <button type="submit" id="submit-form-btn"> Add Household Member </button>

    </form>
    <button id="back-to-prompt">Back </button>

  </div>
</div>

<!-- Edit Household Form -->

<div class = "add-driver-form">
  <div class = "add-driver-form-border">
  <form action = "/add-driver" method = "post" id = "add-driver-form-form"> 
    <div class = "section-d">
      <label for = "full_name" class = "add-driver-form-labels">Driver Full Name: </label>
      <input type="text" id="full_name" name="name" class="add-driver-form-inputs">
    </div>
    <div class = "section-d">
      <label for = "dob" class = "add-driver-form-labels"> Driver DOB: </label>
      <input type="date" id="dateOfBirth" name="dateOfBirth" class="add-driver-form-inputs">
    </div>
    <div class = "section-d">
      <label for = "relation" class = "add-driver-form-labels">Driver Realation: </label>
      <select id="relation" name="relation">
        <option value="self">self</option>
        <option value="spouse">spouse</option>
        <option value="child">child</option>
        <option value="parent">parent</option>
        <option value="sibling">sibling</option>
        <option value="other">other</option>
      </select>
    </div>
    <div class = "section-d">
      <label for = "year" class = "add-driver-form-labels"> Vehicle Year: </label>
     <input type = "text" id = "year" class = "add-driver-form-inputs" name = "year">
    </div>
    <div class = "section-d">
      <label for = "make" class = "add-driver-form-labels">Vehicle Make: </label>
     <input type = "text" id = "make" class = "add-driver-form-inputs" name = "make">
    </div>
    <div class = "section-d">
      <label for = "model" class = "add-driver-form-labels">Vehicle Model: </label>
     <input type = "text" id = "model" class = "add-driver-form-inputs" name = "model">
    </div>
    <div class = "section-d">
      <label for = "vin" class = "add-driver-form-labels">Vehicle VIN: </label>
     <input type = "text" id = "vin" class = "add-driver-form-inputs" name = "vin">
    </div>
    <div class = "section-d">
      <label for = "policyNumber" class = "add-driver-form-labels">Policy number: </label>
     <input type = "text" id = "policyNumber" class = "add-driver-form-inputs" name = "policyNumber">
    </div>
    <button type ="submit" id ="add-driver-submit-btn">Submit </button>
    <button type ="button" id ="add-driver-cancel-btn" >Back </button>
    
    
    
  </form>
  </div>
  </div>

For some reason driver form still displays the menu over everything and when I try to change it a box of the border appears in the middle. I don’t understand why it is working like that I have two previous pop ups that work perfectly except for this one. I tried to affect the visibility as well to no avail.

I need help in creating a table in react with the help of bootstrap

i actually want to create this table for my react project but i am facing issues in this project , can anybody help me out , i need to do it as a project for my department but i am not very familiar with bootstrap i have tried to do it by myself i have managed to make another tables but this particular table is giving me problems!

also can somebody tell how can i make the data to be dynamic like i need it to be fetched from a list also the table data like name , roll no and etc must be editable

import React, { useState } from 'react';

function ExamMarksTable() {
    const [data, setData] = useState([
        "To understand the Basics concepts of networking standards, protocols and technologies.",
        "To learn the different signal transmission, multiplexing techniques.",
        "To learn the role of protocols at various layers in the protocol stacks",
        "To learn the different IEEE standards.",
    ]);

    const [editIndex, setEditIndex] = useState(null);
    const [editedData, setEditedData] = useState([...data]);

    const handleEdit = (index) => {
        setEditIndex(index);
        setEditedData([...data]); // Reset edited data
    };

    const handleInputChange = (event, index) => {
        const newData = [...editedData];
        newData[index] = event.target.value;
        setEditedData(newData);
    };

    const handleSave = (index) => {
        setEditIndex(null);
        setData([...editedData]); // Save edited data
    };

    return (
        <div className="container-fluid w-100 border border-danger border-3 mt-4 text-dark">
            <div className="row">
                <div className="col">
                    <div className="row text-dark no-wrap fs-4 d-flex justify-content-center font-weight-bold">
                        <div className="col-1 fs-4 fw-bold border border-2 px-5 py-5">Sr.No</div>
                        <div className="col-1 fs-4 fw-bold border border-2 px-5 py-5">Roll No.</div>
                        <div className="col-1 fs-4 fw-bold border border-2 px-5 py-5">Prn No.</div>
                        <div className="col-3 fs-4 fw-bold border border-2 px-5 py-5">Student Name</div>
                        <div className="col-6 fs-4 fw-bold border border-2 px-2 py-2">
                        <div className="col-12 fs-4 fw-bold px-2 py-2">CO Attainment from University Exam</div>
                        <div className="col-12 fs-4 fw-bold px-2 py-2 d-flex">
                        <div className="fs-4 fw-bold border border-2 px-2 py-2">ESE</div>
                        <div className="fs-4 fw-bold border border-2 px-2 py-2">Mid Sem</div>
                        <div className="fs-4 fw-bold border border-2 px-2 py-2">PR/OR</div>
                        <div className="fs-4 fw-bold border border-2 px-2 py-2">Term Work</div>
                        <div className="fs-4 fw-bold border border-2 px-2 py-2">Total</div>
                        </div>
                        <div className="col-12 fs-4 fw-bold px-2 py-2 d-flex">
                        <div className="fs-4 fw-bold border border-2 px-2 py-2">70</div>
                        <div className="fs-4 fw-bold border border-2 px-2 py-2">30</div>
                        <div className="fs-4 fw-bold border border-2 px-2 py-2">25</div>
                        <div className="fs-4 fw-bold border border-2 px-2 py-2">25</div>
                        <div className="fs-4 fw-bold border border-2 px-2 py-2">150</div>

                        </div>


                        </div>

                    </div>
                    {data.map((item, index) => (
                        <div className="row align-items-center hover-overlay" key={index}>
                            <div className="col-6 border border-2 px-2 py-3 fs-4 w-25 d-inline-flex align-items-center justify-content-start hover-shadow">
                                <span>{`${index + 1}`}</span>
                                <div>
                                    {editIndex === index ? (
                                        <button className="btn btn-success ms-2" onClick={() => handleSave(index)}>Save</button>
                                    ) : (
                                        <button className="btn btn-light border border-3 ms-3" onClick={() => handleEdit(index)}>Edit</button>
                                    )}
                                </div>
                            </div>
                            {editIndex === index ? (
                                <div className="col-5 border border-2 fs-4 px-2 py-3 w-75">
                                    <input type="text" className="form-control fs-5" value={editedData[index]} onChange={(event) => handleInputChange(event, index)} />
                                </div>
                            ) : (
                                <div className="col-5  border border-top-0 border-2 fs-5 px-2 w-75 " style={{ paddingTop: "23px", paddingBottom: "20px", display: "flex", alignItems: "center" }}>{item}</div>
                            )}
                        </div>
                    ))}
                </div>
            </div>
        </div>
    );
}

export default ExamMarksTable;

Convert regex string to regex object that contains unicode character class escape

I have a data object with regex in it

data = {regex : "/^[p{L} .’_-]+$/u"}

In js file I am using this pattern to match with a string

var s = "check";
var pattern = new RegExp(data.regex);
console.log(pattern.test(s));

The above code is not working. Pattern becomes //^[p{L} .’_-]+$/u/ and is resulting to false and extra slashes are also getting attached to the regex.

How to fix this so the result can be something like this
pattern = /^[p{L} .’_-]+$/u but in regex object?

Postmark send mail to multiple users

I want to send email to multiple users in a single request by putting them all in Bcc and in to I put myself that is my second email so that all the users get mail but I got error that Bcc is not with correct format

const broadCastEmail = async (emails) => {
  // Create a Postmark client with your server token
  const client = new postmark.ServerClient(
    "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  );

  const path = "./public/logo.png";
  const logoAttachment = await createAttachment(path, "Logo_solo.png");
  console.log(emails);

  const emailParams = {
    From: "[email protected]",
    To: "[email protected]", // You can set the primary recipient here
    Bcc: ["[email protected]", "[email protected]"],
    Subject: "Your email subject",
    HtmlBody: "<p>Hello, this is a test email.</p>",
    Attachments: logoAttachment,
  };

  // Send the email
  client
    .sendEmail(emailParams)
    .then((response) => {
      console.log("Email sent successfully");
      console.log(response);
    })
    .catch((error) => {
      console.error("Error sending email:", error);
    });
};

How to deploy a React App on Firebase hosting

How to deploy a React App on Firebase hosting. When I use firebase init, it creates a “public” page and an “index.html” file but nothing appears when accessing the page after deployment. I put all the folders in “public” and fired firebase deploy, but it still didn’t work.

enter image description here

How to change font-size by limiting it to increase or decrease twice using vanilla JS

Currently, I’m able to change the font size once: decrease (-A), default (A) or Increase (A+). If I click the buttons more than once, it does nothing.

What I want is to be able to increase/decrease the font size but limiting it to clicking twice so the font size doesn’t go beyond -/+ 150%.

Example: When I click on -A, the font size reduces to 0.75em. I want this to further reduce it to 0.5em if someone clicks it again but that should be the minimum size it can go. Likewise, font size is increased to 1.25em when A+ is clicked but should not increase beyond 1.5em if a user clicks multiple times.

Demo: https://jsfiddle.net/etfcdu10/

HTML:

<button type="button" onclick="changeSizeByBtn(0.75)" name="btn1">-A</button>
<button type="button" onclick="changeSizeByBtn(1)" name="btn2">A</button>
<button type="button" onclick="changeSizeByBtn(1.25)" name="btn3">A+</button>
<hr />
<div id="container">
  <h1>This is the title</h1>
  <h2>This is a sub title</h2>
  <p>I need to increase the texts here by clicking on A+ button and decrease them by clicking -A button above. <br />
The problem here is that it increase/decrease only once. I want it to increase or decrease twice by say 25%. Not Thrice but just twice. How can I go about doing this?</p>
</div>

JS:

var cont = document.getElementById("container");
function changeSizeByBtn(size) {
  cont.style.fontSize = size + "em";
}

CSS:

div {
  padding: 20px;
  border: 5px solid red;  
}
h1 {
  font-size: 2em;
}
h2 {
  font-size: 1.5em;
}
p {
  font-size: 1em;
}

Block click- in mouseup-event, if mouseup would cause a click

In my mouseup-eventhandler I am currently able to block the next click event with this simple logic:

document.addEventListener('click', e => e.stopImmediatePropagation(), { capture: true, once: true })

But I only want to do it, if the current event will cause a click-event, too! Otherwise the next click-event will just get blocked. Right now I check this by the time difference, but it seams a bit hacky. Is there a better way?

dropbox api create sharedlink not working

So, in my project I send an audio file to Dropbox through Dropbox package, and it works just fine, but I want in the response also a link for the uploaded audio file and this is not provided in the initial upload response. And with some research I found out that there’s a function that can create a shared Link but it’s not working and it’s giving 400 bad request for some reason. I really tried different things like putting the parent path before the audio file path, and using the lower version of the path and using the audio file id but it’s all giving 400 bad request.

  const handleSave = async () => {
    setIsSaved(true);
    setRecord(false);
  
    if (audioBlob) {
      const currentDate = new Date();
      const fileName = `recorded_audio_${currentDate.toISOString()}.wav`;
      try {
        const response = await dbx.filesUpload({
          path: `/${fileName}`,
          contents: audioBlob,
        });
        console.log("File uploaded successfully!", response);
        setShowDownload(false);
  
        const uploadedFile = response.result;
  
        const shareLink = await dbx.sharingCreateSharedLinkWithSettings({
          path: uploadedFile.path_display,
          requested_visibility: 'public'
        });
  
        console.log("Share link created:", shareLink.result.url);
  
      } catch (error) {
        console.error("Error uploading file to Dropbox:", error);
      }
    }
  };

and this is response in the console:

Record.tsx:80 
 POST https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings 400 (Bad Request)

Record.tsx:87 Error uploading file to Dropbox: DropboxResponseError: Response failed with a 400 code
    at dropbox.js?v=2aef07da:1071:11
    at async handleSave (Record.tsx:80:35)

enter image description here

Button doesn’t work second time while moving contents

The following code generates blue text boxes when OptionOne or OptionTwo is selected. For example, when the Show Options button is clicked, a blue text box appears on the left side and then I can enter row and column values and hit the calculate button to figure out the cell number where it needs to be moved using the Move Text Content! button.

The problem I’m facing is, the move button works fine for the first time. However, when I select the OptionTwo from the dropdown and calculate new cell number and hit the Move Text Content! button, it doesn’t work as shown below.

/*

Requires jquery + UI

https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js

https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js

*/

$('[name="optionSelection"]').change(function () {
      //clean up the divs inside div with id phrase
    $("#phrase").empty();
  });

  function showOptions() {
    console.log("hii");
    console.log($("#optionSelection").val());
    var html;
    if ($("#optionSelection").val() == 1) {
      for (i = 0; i < 3; i++) {
         
            html = "<div data-id="+i+"><span class='words' data-id="+i+">OptionOne#"+i+"</span></div>";
            $("#phrase").append(html);
      }
      
    }
    else {
      for (j = 0; j < 5; j++) {
         
        html = "<div data-id="+j+"><span class='words' data-id="+j+">OptionTwo#"+j+"</span></div>";
       $("#phrase").append(html);
    }
   // $("#phrase").append(html);
  }
}


  $(".words").draggable({
    revert: function (event, ui) {
      var bRevertingPhrase = this.closest("#drop-em");

      if (!bRevertingPhrase.length) {
        var phraseID = $(this).data("id");
        var phraseHomeID = $(this).parent().data("id");

        //If the child and parent ids don't match, we move the child to the correct parent
        if (phraseID !== phraseHomeID) {
          var correctCell = $("#phrase").find(
            "div[data-id='" + phraseID + "']"
          );
          correctCell.prepend(this);
        }
      }
      return !event;
    },
  });
  $("#drop-em > div").droppable({
    drop: function (ev, ui) {
      $(ui.draggable)
        .detach()
        .css({ top: 0, left: 0 })
        .appendTo($(this).find(".content:empty"));
      //$("#move-text").addClass("disabled");
    },
  });
  $("#phrase > div").droppable({
    drop: function (ev, ui) {
      $(ui.draggable).detach().css({ top: 0, left: 0 }).prependTo(this);
    },
  });

  const myButton = document.querySelector("#move-text");
  myButton.addEventListener(
    "click",
    () => {
      fill();
    },
    {
      once: true,
    }
  );

  var reOrder = [];
  function fill() {
    const cells = document.querySelectorAll("#phrase > div > span");
    var newLoc = "";
    //myButton.classList.add("disabled");

    cells.forEach((cell, index) => {
      newLoc = document.querySelector(
        ".item:nth-child(" + reOrder[index + startPos - 1] + ") .content "
      );
      newLoc.append(cell);
      newLoc.classList.add("moved");
    });
  }
  function reArrange() {
    var limit1 = 85;
    var limit2 = 91;

    for (let loop = 0; loop < 8; loop++) {
      for (let i = 0; i < 6; i++) {
        reOrder.push(limit1 + i);
      }
      limit1 = limit1 - 12;
    }
    for (let loop = 0; loop < 8; loop++) {
      for (let j = 0; j < 6; j++) {
        reOrder.push(limit2 + j);
      }
      limit2 = limit2 - 12;
    }
  }
  reArrange();

  /* get cell number */

  const myRow = document.querySelector("#inp1");
  const myCol = document.querySelector("#inp2");
  var startPos = 0;
  const myCalculateButton = document.querySelector("#calculate");
  const myAnswer = document.querySelector("#cellnum");
  myCalculateButton.addEventListener("click", () => {
    var rowNumber = myRow.value.toUpperCase();
    var colNumber = myCol.value;
    var result = 0;
    switch (rowNumber) {
      case "A":
        rowNumber = 42;
        break;
      case "B":
        rowNumber = 36;
        break;
      case "C":
        rowNumber = 30;
        break;
      case "D":
        rowNumber = 24;
        break;
      case "E":
        rowNumber = 18;
        break;
      case "F":
        rowNumber = 12;
        break;
      case "G":
        rowNumber = 6;
        break;
      case "H":
        rowNumber = 0;
        break;
    }

    if (colNumber < 7) {
      result = rowNumber + parseInt(colNumber);
    } else {
      result = rowNumber + 42 + parseInt(colNumber);
    }
    myAnswer.innerHTML = result;
    startPos = result;
  });
  
 
html {
    box-sizing: border-box;
  }
  *,
  *:before,
  *:after {
    box-sizing: inherit;
  }
  body {
    counter-reset: columnCount 1 alphaCount cellCount;
  }
  h1 {
    text-align: center;
  }
  .wrap {
    display: flex;
    gap: 2rem;
    position: relative;
    padding-left: 220px;
  }

  .grid {
    margin: auto;
    display: grid;
    flex: 1 0 0;
    grid-template-columns: repeat(12, 1fr);
    padding-top: 1.5rem;
  }

  .item {
    position: relative;
    background-color: #f9f9f9;
    border: 1px solid grey;
    aspect-ratio: 1/1;
    counter-increment: columnCount;
    min-width: 0;
    transition: background 1s ease;
  }
  .item:nth-of-type(12n + 1) {
    counter-increment: alphaCount;
  }
  .item:nth-of-type(12n + 1)::before {
    content: counter(alphaCount, upper-alpha);
    position: absolute;
    display: flex;
    align-items: center;
    top: 0;
    bottom: 0;
    left: -1.75rem;
    color: red;
    pointer-events: none;
  }
  .item:nth-of-type(n + 13)::after {
    display: none;
  }
  .item::after {
    content: counter(columnCount);
    position: absolute;
    left: 0;
    right: 0;
    text-align: center;
    top: -1.75rem;
    color: red;
    pointer-events: none;
  }
  .content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
    height: 100%;
    overflow: auto;
    color: #000;
    padding: 1rem;
    word-wrap: break-word;
    counter-increment: cellCount;
  }

  .words {
    cursor: move;
    transition: padding 0.5s ease;
  }
  .content:has(.ui-draggable-dragging) {
    overflow: visible;
  }
  .ui-droppable-active .content {
    overflow: visible;
  }
  .words.ui-draggable-dragging {
    background: blue;
    padding: 5px 10px;
    border-radius: 6px;
    z-index: 999;
    color: #fff;
    display: block;
    width: 50px;
    height: 50px;
    overflow: hidden;
  }
  #phrase {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    color: #fff;
    width: 150px;
    overflow: auto;
    z-index: 2;
    display: flex;
    flex-direction: column;
    margin: 1rem 0 0.5rem;
  }
  #phrase > div {
    margin: 0 0 10px;
    width: 150px;
    padding: 5px 10px;
    background: #007bff;
    border: 2px solid #007bff;
    border-radius: 6px;
    color: #fff;
  }
  #phrase > div:empty {
    background: #fff;
    border-style: dashed;
    padding: 0px 25px;
    min-height: 30px;
  }

  .moved {
    animation: fade 3s ease;
  }
  @keyframes fade {
    0% {
      opacity: 0;
    }
    50% {
      opacity: 1;
      background: red;
    }
  }

  .item .content::before {
    content: counter(cellCount);
    position: absolute;
    top: 2px;
    left: 2px;
    font-size: smaller;
    color: #666;
    border-radius: 50%;
    border: 1px solid red;
    background: white;
    width: 1.2rem;
    height: 1, 2rem;
    display: grid;
    place-items: center;
  }

  #move-text.disabled {
    cursor: none;
    pointer-events: none;
    opacity: 0.5;
  }
  #phrase:has(.ui-droppable-active) {
    overflow: visible;
  }

  input,
  button,
  label,
  p.target {
    display: block;
    margin: 0 0 0.4rem;
    color: #000;
  }
  p.target {
    margin: 0 0 1rem;
  }
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
  <!-- You'd need to set up something different for touch devices though -->

  <h1>Move testings</h1>
  <div class="wrap">
    <div>
      <label for="optionSelection">Select options</label>
      <select name="optionSelection" id="optionSelection">
        <option value="1">OptionOne</option>
        <option value="2">OptionTwo</option>
      </select>
    </div>
    <div>
      <button id="showOptions" onclick="showOptions()" type="button">
        Show Options
      </button>
    </div>
    <div>
      <label for="inp1">Enter a row A - H</label>
      <input id="inp1" placeholder="Enter Row" />
      <label for="inp2">Enter a column 1 - 12</label>
      <input id="inp2" placeholder="Enter Column" />
      <button id="calculate">Calculate</button>
      <p class="target">The cell number is <b id="cellnum">?</b></p>
      <button id="move-text" type="button">Move Text Content!</button>
    </div>
    <div id="phrase">
      <!-- remove whitespace from  inside div html and then we can use :empty in css to change background -->
      <!-- <div data-id="1"><span class="words" data-id="1">H1 text</span></div>
      <div data-id="2"><span class="words" data-id="2">H2 text</span></div>
      <div data-id="3"><span class="words" data-id="3">H3 text</span></div>
      <div data-id="4"><span class="words" data-id="4">H4 text</span></div>
      <div data-id="5"><span class="words" data-id="5">H5 text</span></div>
      <div data-id="6"><span class="words" data-id="6">H6 text</span></div>
      <div data-id="7"><span class="words" data-id="7">G1 text</span></div>
      <div data-id="8"><span class="words" data-id="8">G2 text</span></div>
      <div data-id="9"><span class="words" data-id="9">G3 text</span></div>
      <div data-id="10"><span class="words" data-id="10">G4 text</span></div> -->
    </div>

    <div id="drop-em" class="grid">
      <div class="item">
        <div class="content"></div>
        <!-- must have no spaces inside .content -->
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
      <div class="item">
        <div class="content"></div>
      </div>
    </div>
  </div>

For your testing, make sure to select different row and column number if you are testing move button second time as I don’t have validation in place yet which will prevent the move from moving to the same place again ( where something already exists in the cell).

Updating the Source Code of an App Deployed Through Google Cloud

I have an app hosted on Google Cloud service, and the code for the app is also on GitHub. I’ve made changes to the code on GitHub, but now I need to know how to update Google Cloud to reflect what I changed. How do I do this?

I’ve searched the pages available to me through console.cloud.google.com and there’s nowhere that I’ve found where I can even see the code is being held, let alone make changes to it.

JS – Editing a child object of an object

Here’s the data (set to the state name of comments)

    [
{
    "id": 1,
    "content": "Impressive! Though it seems the drag feature could be improved. But overall it looks incredible. You've nailed the design and the responsiveness at various breakpoints works really well.",
    "createdAt": "1 month ago",
    "score": 12,
    "user": {
        "image": {
            "png": "./images/avatars/image-amyrobson.png",
            "webp": "./images/avatars/image-amyrobson.webp"
        },
        "username": "amyrobson"
    },
    "replies": []
},
{
    "id": 2,
    "content": "Woah, your project looks awesome! How long have you been coding for? I'm still new, but think I want to dive into React as well soon. Perhaps you can give me an insight on where I can learn React? Thanks!",
    "createdAt": "2 weeks ago",
    "score": 5,
    "user": {
        "image": {
            "png": "./images/avatars/image-maxblagun.png",
            "webp": "./images/avatars/image-maxblagun.webp"
        },
        "username": "maxblagun"
    },
    "replies": [
        {
            "id": 3,
            "content": "If you're still new, I'd recommend focusing on the fundamentals of HTML, CSS, and JS before considering React. It's very tempting to jump ahead but lay a solid foundation first.",
            "createdAt": "1 week ago",
            "score": 4,
            "replyingTo": "maxblagun",
            "user": {
                "image": {
                    "png": "./images/avatars/image-ramsesmiron.png",
                    "webp": "./images/avatars/image-ramsesmiron.webp"
                },
                "username": "ramsesmiron"
            }
        },
        {
            "id": 4,
            "content": "I couldn't agree more with this. Everything moves so fast and it always seems like everyone knows the newest library/framework. But the fundamentals are what stay constant.",
            "createdAt": "2 days ago",
            "score": 2,
            "replyingTo": "ramsesmiron",
            "user": {
                "image": {
                    "png": "./images/avatars/image-juliusomo.png",
                    "webp": "./images/avatars/image-juliusomo.webp"
                },
                "username": "juliusomo"
            }
        }
    ]
}]

This code successfully deletes the correct comment clicked on, even if it’s a child comment of a parent comment

  const { comments, setLoading } = useContext(CommentsContext);

function handleDelete(e) {
    setLoading(true);

    function deleteComment(id, arr) {
        arr.forEach(function (item, index) {
            if (item.id == id) {
                arr.splice(index, 1);
            } else if (item.replies && item.replies.length > 0) {
                deleteComment(id, item.replies);
            }
        });
    }

    deleteComment(e.target.id, comments);

    setTimeout(() => {
        setLoading(false);
    }, 100);
}

So I copied it and have been trying to rework it to allow me to edit the comment that’s clicked on

 function handleEdit(e) {
    setLoading(true);

    function editComment(id, arr) {
        arr.forEach(function (item, index) {
            if (item.id == id) {
                console.log("first layer");
            } else if (item.replies && item.replies.length > 0) {
                console.log("second layer");
            }
        });
    }

    editComment(e.target.id, comments);

    setTimeout(() => {
        setLoading(false);
    }, 100);

From here I can generate the console log of “second layer” when clicking on a child comment but it’s pulling the information from the parent comment. I.e. I’m clicking the child comment with the id of 4 but it’s giving me the info of it’s parent comment with the id of 2.

I tried running a loop and for each within the else if but it just didn’t work at all.

The idea is to click the edit button, it changes the comment’s content to a textarea with the previous content autofilling the input, changing something, and having that save over the comments state.

NodeJS login and authorization (Express)

I have a NodeJS backend and an HTML, JS and CSS frontend (separate servers). My login.html works and the session works as well (console.log to the server which displays session id and session email). After a user logs in its supposed to take them to dashboard.html IF LOGGED IN, if not, redirects them to login.html

After I login successfully (session is set), I get directed to dashboard.html and then back to login.html right away – even though my session has started.

Here is my frontends js/auth.js

document.addEventListener("DOMContentLoaded", function () {
  // Check backend for user session
  fetch("http://localhost:3000/api/user-auth")
    .then((response) => {
      if (!response.ok) {
        throw new Error("Network response was not ok");
      }
      return response.json();
    })
    .then((data) => {
      if (!data.authenticated) {
        window.location.href = "login.html"; // Redirect if not authenticated
      }
    })
    .catch((error) => {
      console.error("Error:", error);
    });
});

Here is my servers user-auth

const express = require("express");
const router = express.Router();

router.get("/", (req, res) => {
  // Check if user is authenticated based on session data
  if (req.session.userId) {
    // User is authenticated
    res.json({ authenticated: true });
  } else {
    // User is not authenticated
    res.json({ authenticated: false });
  }
});

module.exports = router;

Here is the relevant part of my backend login.js

const user = result[0];
      // Compare passwords
      bcrypt.compare(userPassword, user.password, (compareErr, match) => {
        if (compareErr) {
          return res.status(500).json({ message: compareErr.message });
        }
        if (!match) {
          return res.status(401).json({ message: "Incorrect password" });
        }

        // Set session variables to indicate user is logged in
        req.session.userId = user.id;
        req.session.userEmail = user.email;
        console.log(req.session.userId);
        console.log(req.session.userEmail);

        // Send JSON response with redirect URL
        res.json({ redirect: "dashboard.html" });
      });

And my session middleware:

app.use(
  session({
    secret:
      "", // Removed from the post but is set.
    resave: false,
    saveUninitialized: true,
  })
);

Nothing much else, as I am fairly new to NodeJS.