Angular reactive from getting “Cross-Site Request Forgery” issue in the fortify scan

in angular application we are using the reactive form and formGroup,its working fine but when i run the fortify scan we are getting the issue like

    "The form post at xxxx.component.html line 4 must contain a user-specific
 secret in order to prevent an attacker from making unauthorized requests."

.html

<div class="row no-gutters">
    <div class="col diagonal center">
        <form [formGroup]="searchForm">
            <div class="row ldes-mg m-1">
               // form controls here 
              // form controls here 
            </div>
        </form>
    </div>
</div>

issue shown on <form [formGroup]="searchForm">

there are some article which suggest to implement “Backend CSRF Token Setup: Make sure your backend framework is set up to provide a CSRF token.” but in this application there is no provision for that

Can anyone guide on this ?

After a lot of searching we have enabled autoplay with voice onscroll on our website but there is a problem

After searching a lot, we started autoplay with sound on our website but there is a problem that whenever the video comes inside the viewport, it starts automatically but when another video comes in the viewport, the above video should stop. Both videos play at the same time as long as both remain within the viewport.
This my code



$(window).scroll(function(e){

    if (!document.pictureInPictureElement) {

        $('.plyrr-<?php echo $wo['media']['storyId'].$rand ; ?>').each(function(){

            if ($(this).is(":in-viewport")) {

                jQuery(this).get(0).play();

            } else {

                $(this)[0].pause();

            }

        });

    }

});

It’s not working like instagram, facebook only one video play a time please set Viewport size if double video in viewport same time then one play second stop
Please check – https://pintrafeed.com/directory[enter image description here](https://i.sstatic.net/Uma6TDXE.jpg)

Handling same tabs in cypress [closed]

Im facing multiple tabs issue in cypress while testing.

I don’t know how to handle cypress testing in same tabs? Anyone please explain me the technique to maintain cypress testing in same tab.
When I am testing gmail testing in same page.
It is redirecting to the next tab. I don’t no how to resolve this issue.
Anyone please give me the solution for this issue.

how to call an event in for fetching the latlng?

<gmp-map [center]="center" [scrollwheel]="true" [zoom]="zoom" map-id="roadmap" style="height:400px;width:100%;" Type="map"><gmp-advanced-marker *ngFor="let marker of markers"[position]="marker.position"[title]="marker.title"[label]="marker.label"[options]="marker.options"></gmp-advanced-marker> </gmp-map>
<google-map class="px-0" height="300px"   width="100%"[center]="center"[options]="options"[latitude]="lat"[longitude]="lng"[scrollwheel]="true"(mapClick)="onMapClick($event)"[zoom]="zoom"language="en"><map-marker*ngFor="let marker of markers"[position]="marker.position"[options]="marker.options"></map-marker><label class="current-location-btn" (click)="getCurrentLocation()">{{ "Locate Me" | language | async }}</label></google-map>

how to use mapclick event in gmp-map i tried the same method but not working

i want to call an event in gmp-map like i call in google-map i metioned above

Creating an S-curved Stepper Component

I’m trying to build a custom stepper component with an S-curve shape in React I’ve explored using the MUI Stepper component but couldn’t achieve the desired design. even I tried pure html and CSS also but couldn’t make it near.

I’m quite new to web development, so I’m struggling to even create a basic curved line.

enter image description here

looking for documentation, sample code or anything might helpful to create this component.

How to pass modular styles through props in React?

I have a component:

import React from 'react';
import s from './SectionsTitle.module.css';

const SectionsTitle = (props) => {
  return (
    <div className={props.styleTitle}>
      {props.whiteFraction}<span{props.redFraction}</span> 
    </div>
  );
};

export default SectionsTitle;

I pass styleTitle through props from the parent component:

<SectionsTitle styleTitle='s.SectionsTitle' /> 

Is it possible to pass s.SectionsTitle through props somehow? It doesn’t work for me this way

How do I create a Simple Marker Symbol based on distance in the ArcGIS Map JS SDK?

Using the ArcGIS Map JS SDK, I created a map with a simple marker symbol created on map click. Here is the code:

require(["esri/Map", "esri/views/MapView", "esri/Graphic", "esri/layers/GraphicsLayer"], (Map, MapView, Graphic, GraphicsLayer) => {
        map = new Map({
            basemap:  "streets-vector"
        });
        
        const view = new MapView({
            container: "map_details",
            map: map,
            zoom: 16,
            center: [INIT_COORDINATES.LNG, INIT_COORDINATES.LAT]
        });
        
        graphicsLayer = new GraphicsLayer();
        map.add(graphicsLayer);
        
        view.when(() => {
            view.on("click", (event) => {
                pointGraphic = new Graphic({ 
                    geometry: { 
                        type: "point", 
                        longitude: event.mapPoint.longitude, 
                        latitude: event.mapPoint.latitude
                    }, 
                    symbol: { 
                        type: "simple-marker", 
                        size: 50, // how do I set it to 50 meter ? Its unit is pt now 
                        color: [226, 119, 40, 0.5] 
                    }
                }); 
                graphicsLayer.add(pointGraphic);
            });
        });
    });

How do I set it to 50 meter ? Its unit is pt now. Currently, the marker symbol is still 50pt no matter what is the zoom level. I expect the marker will adjust the size based on the zoom level (i.e. always 50 meter)

On the other hand, how do I set the language of the map? I tried to use:

map = new Map({
    basemap:  "streets-vector",
    language: "es"
});

but the map is still showing English language.

document.execCommand and document.queryCommandState doesn’t work in Svelte

I want to create a text editor, but there are some confusing problems that have come up :

  • The text formatting doesn’t work unless text is selected first
  • The color change on the buttons when the formatting is active sometimes works and sometimes doesn’t. I’ve tried three methods : wrapping it in a function didn’t work, adding an arrow function () => in the onClick makes the color appear active even before I click, and when I do click, it doesn’t change. Using document.queryCommandState directly without wrapping in a function didn’t work either.

And is using bind:innerHTML as I did safe for security? If it’s not safe, what is the safe way?

<script>
    function formatText(command){
        document.execCommand(command, false, null);
    }
    
    function isFormatActive(command){
        return document.queryCommandState(command);
    }
</script>

<div class="bg-black text-white font-lg font-bold">
    <button class:bg-emerald-950={isFormatActive("italic")} on:click={() => formatText("italic")} class="p-4">
        <i>I</i>
    </button>
    <button class:bg-emerald-950={() => isFormatActive('bold')} on:click={() => formatText('bold')} class="p-4">
        <b>B</b>
    </button>
    <button class:bg-emerald-950={document.queryCommandState('underline')} on:click={() => formatText('underline')} class="p-4">
        <u>U</u>
    </button>
</div>
<div class="bg-emerald-500 text-white p-4 rounded-lg focus:border-none focus:outline-none" contenteditable="true">hello</div>

state variables returns undefined

I need help with managing react states, I can’t seem to wrap my head around it.

I have a component that receives the id of a database entry from another page via useLocation, I then use that id with an axios get request to pull the rest of the data into an array. However, when I am trying to use the data from the get request as a defaultValue for an MUI TextField it doesn’t render the data naturally, the states returns as undefined after the page loads. I have to set the TextField’s key to the get request data (a work around I found in the web) to render. Then when I try to submit the form, the value from the Textfield displays as undefined though the Texfield contains the data from the get request.

const location = useLocation();
const [info, setInfo] = useState([]);

useEffect(()=>{
  axios
    .get("//localhost:3001/Info/" + location.state.id)
    .then((response)=>{
      setInfo(response.data);
  })
});

const validationSchema = Yup.object().shape({});

const formik = useFormik({
  initialValues: {
    name: info.name
  },
  validationSchema: validationSchema,
  onSubmit: (values) => {
    console.log(values) // displays {name: undefined, .....}
  }
});

return(
  <>
    <Container>
      <form onSubmit = {formik.handeSubmit}>
        <TextField
          id = "name"
          label = "Name"
          name = "name"
          onChange = {formik.handleChange}
          onBlur = {formik.handleBlur}
          key = {info.name} //Textfield blank without setting key
          defaultValue = {info.name}
        />
        <Button type = "Submit"> Submit </Button>
      </form>
    </Container>
  </>
);

I am expecting the TextFields default values to render correctly without declaring a key as a work around. Also, I expect the values of the textfields to contain the initialvalues from the formik declaration on submit.

Ensure that Promise has been resolved before rendering view

What specific syntax needs to be changed in the code below in order for the value returned by the currentSession() function to correctly set the html that is rendered to the user in the web browser?

Specifically, what needs to be changed so that the console.log("other groups is: ", groups); line returns a valid array of groups, and so that the logic in the {isGroupOne ? <p>Welcome back!</p> : <p>Please log in.</p>} line is able to execute with isGroupOne having been returned as True?

USE CASE:

A React component needs to render different content for users that are in different user groups. The groups for a given user are indeed returned from a backend service.

PROBLEM:

The problem is that the React component is printing out the user’s groups as a pending promise instead of as a valid array of group names that can be transformed into a Boolean to indicate whether or not the user is in a specific group.

As a result, the wrong content is being printed to the web browser in the example broken code below. Currently, Please log in. is being printed in the browser, even though you can see from the logs below that the promise eventually resolves to give isGroupOne the value of true.

MINIMAL CODE TO REPRODUCE PROBLEM:

Here is the minimal code required to reproduce the problem:

import { fetchAuthSession } from 'aws-amplify/auth';

function Index() {
  let isGroupOne = false;

  async function currentSession() {
    try {
      const { accessToken, idToken } = (await fetchAuthSession()).tokens ?? {};
      const groups = accessToken["payload"]["cognito:groups"]
      console.log("these groups: ", groups);
      return groups;
    } catch (err) {
      console.log(err);
    }
  }

  const groups = currentSession().then(groups => {
    console.log("those groups is: ", groups);
    //iterate groups array to see if "GroupOne" is in the array
    groups.forEach(group => {
      if (group === "GroupOne") {
        console.log("User is in GroupOne group");
        isGroupOne = true;
        console.log("isGroupOne: ", isGroupOne);
      }
    });

  });
  console.log("other groups is: ", groups);

  return (
    <div>
        {isGroupOne ? <p>Welcome back!</p> : <p>Please log in.</p>}
    </div>

  );
}

export default Index;

LOGS ILLUSTRATING THE PROBLEM:

The following is printed to the console when the page defined by the above minimal code is rendered in the web browser:

other groups is:  Promise {<pending>}
index.js:29 other groups is:  Promise {<pending>}
index.js:10 these groups:  ['GroupOne']
index.js:18 those groups is:  ['GroupOne']
index.js:22 User is in GroupOne group
index.js:24 isGroupOne:  true
index.js:10 these groups:  ['GroupOne']
index.js:18 those groups is:  ['GroupOne']
index.js:22 User is in GroupOne group
index.js:24 isGroupOne:  true

Google Apps Script Web App: Unable to Load HTML Pages Based on URL Parameters

I am experiencing an issue with a Google Apps Script web app I developed. Despite following standard procedures, the app fails to load specific HTML pages based on URL query parameters. Here are the details:
Issue Description
Problem: The web app does not navigate to different pages (such as ‘index’, ’employee’, ‘admin’) based on the URL query parameter page. The URL does not change, and I receive an error message instead of the expected content.
Error Message: “Sorry, unable to open the file at this time. Please check the address and try again.
Steps Taken
Project Setup:

The project includes index, employee, and admin HTML files, referenced without the .html extension in the code.
A doGet function handles URL query parameters to determine which HTML file to serve:

Testing and Debugging:
Verified that file names are correct and match the references in the code.
Checked browser cache and tested in incognito mode to rule out caching issues.
Ensured proper deployment and public access settings.
Monitored network requests and console logs for errors.
Issue Persistence:
The problem persists with minimal HTML content and correct setup.
URLs used include parameters like ?page=admin, but the app does not navigate to the correct page.
Additional Context
Deployment URL: [Your Deployment URL]
Attempts: Multiple re-deployments, browser tests, and code simplifications have been tried without success.
Request
Could you please assist in diagnosing the issue? Are there any known issues with handling URL parameters in Google Apps Script web apps or potential configurations I might be missing? Any guidance or additional steps to resolve this would be greatly appreciated.

Thank you for your assistance.

Proper way to remove a Vue component

What is the correct way to remove Vue child component? I found two ways of doing it.

  1. Emit an event from child component to parent component and parent can remove the child component.
  2. Use v-if inside child component and child component can toggle the condition.

I am more leaning toward the second approach since we don’t have to force parent components to implement listener when it uses this child component. e.g: if this child component is used at 100 places, all those places have to listen for the child custom close event.

Can anyone explain what happen under the hood for both scenario? Is there a different way to remove it? Thanks.

Repl for this example: vue playground

Parent component

<script setup>
import { ref } from 'vue';
import DialogBasic from './DialogBasic.vue';

const isDialogShown = ref(true);
const closeChildDialog = () => isDialogShown.value = false;

</script>

<template>
  <div>
    <h1>Parent Component </h1>
    <DialogBasic
      v-if="isDialogShown"
      @parentCloseDialog="closeChildDialog"
    />
  </div>
</template>

Child component

<script setup>
import { ref } from 'vue';
const isShown = ref(true);
const closeMyself = () => isShown.value = false;

</script>

<template>
  <div v-if="isShown" class="dialog">
    <h1>Dialog Component</h1>
    <button @click="$emit('parentCloseDialog')">Parent closes dialog</button>
    <button @click="closeMyself">Dialog closes itself</button>
  </div>
</template>

<style scoped>
.dialog {
  background-color: aliceblue;
  outline: solid red 1px;
  row-gap: 5px;;
  width: 300px;
  display: flex;
  flex-direction: column;
}
</style>

Javascript/CSS Display styling won’t change

const hamburgerMenuBtn = document.getElementById("hamburger-menu-button");

hamburgerMenuBtn.addEventListener("click", function() {
  hamburgerPopupToggle()
});

function hamburgerPopupToggle() {
  console.log("Button pressed");
  const hamburgerMenuPopup = document.getElementById("hamburger-menu-popup");
  if (hamburgerMenuPopup.style.display === "block") {
    hamburgerMenuPopup.style.display = "none";
    console.log(hamburgerMenuPopup.style.display);
  } else {
    hamburgerMenuPopup.style.display = "block";
    console.log(hamburgerMenuPopup.style.display);
  }
}
#hamburger-menu-popup { display: none; }
<div class="hamburger-menu">
  <span id="hamburger-menu-button">menu</span>
  <div id="hamburger-menu-popup">
    <div id="home-button">Home</div>
    <div id="create-post">Create a Post</div>
  </div>
</div>

The popup opens
(https://i.sstatic.net/4hlVl4VL.png)
But then instead of setting display style back to “none”, it sets it to “unset !important”, BUT it logs that it’s “none” (https://i.sstatic.net/DadeuwQ4.png)(https://i.sstatic.net/bmL9RzHU.png)

So, for some reason it logs what was supposed to happen, but the CSS doesn’t change whatsoever. (It changes, but not as expected)