Next+Nextauth Get user’s session as a ServerSideProp

I’m trying to implement Facebook login and session by using nextauth in a next.js project.
once the user is authenticated I want to retrieve the session and pass it to my component as a server-side prop to avoid unnecessary load time

My […nextauth.js] file

import NextAuth from "next-auth"
import FacebookProvider from "next-auth/providers/facebook";

export default NextAuth({
  // Configure one or more authentication providers
  secret: process.env.SECRET,
  providers: [
    FacebookProvider({
      clientId: process.env.FACEBOOK_CLIENT_ID,
      clientSecret: process.env.FACEBOOK_CLIENT_SECRET,
    }),
    // ...add more providers here
  ],
})

I’ve double-checked my env variables FACEBOOK_CLIENT_ID FACEBOOK_CLIENT_SECRET NEXTAUTH_URL and SECRET

my _app.js file

import "../styles/globals.css";
import { SessionProvider } from "next-auth/react"

export default function App({
  Component, 
  pageProps: { session, ...pageProps }
}) {
  return (
    <SessionProvider session={session}>
      <Component {...pageProps} />
    </SessionProvider>
  )
}

In my index.js component, I’m handling the login

import { useSession, signIn, signOut,getSession } from "next-auth/react"
import Head from 'next/head'
import Header from '../components/Header'
import Login from '../components/Login'

export default function Home({session}) {
  if (!session) return <Login></Login>
  return (
    <div >
      <Head>
        <title>Facebook</title>
      </Head>
      <h1>Signed in as {session.user.email}</h1>
      <Header/>
      <main>
        {/* Sidebar */}
         {/* feed */}
         {/* widgets */}
      </main>
    </div>
  )
  
}
export async function getServerSideProps(context) {
  const session = await getSession(context)
  return {
    props: { session }
  }
}

In mi Login.js component I’m just using the signIn method provided by next auth

The thing is:

  1. When I try to retrieve the session by using getServerSideProps it doesn’t provide me a session and I cannot get to the home page, BUT if I instead use the custom hook inside the component, I get a session and everything works fine, but I think it is better if I pass the session as a serverside prop
const session = await getSession() //this works but is client-side
  • Is there something I’m missing out on? I’ve read the docs and followed the steps but it doesn’t quite work

  • besides Is there a difference between next-auth/react and next-auth/client?
    I have “next-auth”: “^4.0.0-beta.7” package installed in this proyect

If anyone could shed some light over this topic and on why I cant get the session as a serverSide prop I would be thankful.

sql php. Get id from other table then insert into table. I want to click the button then answer current question

<?php require_once('connection.php');  
session_start();

if (isset($_POST['Submit']))
{  
    $answ = $_POST['answ'];      
    $email = $_SESSION['email']; 


    $insert = "INSERT INTO answerList (answ,queID,email) SELECT questionList.queID FROM questionList   " ;
    $result = mysqli_query($con, $insert);
 
    if (!$result) {
        echo "<script>alert('ERROR !!!!! '); location='faq.php';</script>";
    }
    else {
        echo "<script>alert('Successful Post'); location='faq.php'; </script>";
    }
    


}
?> 

I have 3 table
table 1: users(email, password)
table 2: question(questionID, questionContent, email)
table 3: answer(answerID, answerContent, questionID, email)

how can i connect questionID into table 3?
i already do the login and add question sql . but how can i add the answer to current question with logged email?

a table have question. and each question have answer button

Filtering on multiple conditions using javascript filter

Before anyone calls duplicate please read it through first…

I was trying to use the filter function with multiple conditions but doesn’t seem to work and alot of solutions to this roughly come out to say I can do…

const data = [
    {CatalogID: -1, SectionID: 0},
    {CatalogID: 2, SectionID: 9},
    {CatalogID: 2, SectionID: 9},
    {CatalogID: -1, SectionID: 0},
    {CatalogID: -1, SectionID: 0},
    {CatalogID: 3, SectionID: 6},
    {CatalogID: 3, SectionID: 6},
    {CatalogID: -1, SectionID: 0},
    {CatalogID: 3, SectionID: 6}
]

data.filter(f=>f.SectionID == 6 && f.SectionID == 0 && f.CatalogID == -1)

let a = data.filter(function(e) {
        return e.SectionID == 6 && e.SectionID == 0 && e.CatalogID == -1
    });
console.log(a);

But those return empty… But when I loop through the data object, like this…

let holder = [];
for(let i = 0; i < data.length; i++){
    if(data[i].SectionID === 6 || data[i].SectionID === 0 || data[i].CatalogID === -1) holder.push(data[i]);
}
console.log(holder);
holder = [];

Then it does the job, but its not pretty.

Is there something glaringly obvious that is wrong with the code I provided, that is not popping out at me?

Large position replace using PHP string replace

It easy to replace a position of code from external website string but when it come to large than how can we replace it?

Code i want to replace :

<script data-cfasync="false" src="/cdn-cgi/scripts/5c5dd728/cloudflare-static/email-decode.min.js"></script><script nonce="d5951f1b7cde348759b0310ef405830a">
  window.RETROVISION = {
    "homepage": {
      "__render-farm": {"navi":{"variation":"logged_out","darwin":{"mono.corePages_indexController_transactionAccounts":false,"mono.navigation_web_moneyCenterTab":true,"mono.navigation_web_hideMyRecsBadge":false,"mono.taxhub_enabled":true,"mono.enableCardsInWallet":false,"mono.should_show_ciw_in_nav_cc_dropdown":false,"mono.tax_navbar_inseason":false,"mono.navigation_web_nativeUpsell":"control","mono.tax_hub_holdout":true,"autos.purchase_offers_navi_url_enabled":true,"js.cardsInWallet_holdout":false,"js.navi_voter_roadmap_isEnabled":false,"js.navi_voter_roadmap_text":"Voterx20Roadmap","js.reliefCenter_navbar_badge_text":"control","js.useNewLoginNavi":false,"savings.navbar_enabled":true,"mortgage.l1_link_in_authed_navi":true,"mortgage.l1_link_in_unauthed_navi":true,"savings.checking_be_eligibility_flag_v2":true,"savings.billpay_eligible":true,"mortgage.mweb_navi_new_dashboard_link":"new","coreProduct.dweb_stickyTopEnabled":false,"portals.reliefCenter_isEnabled":true,"portals.tax_nav_redirect_enabled":false,"portals.tax_surface_eligibility_unauth":true,"mono.tax_navbar_badge_text":"control","mono.tax_unauth_navbar_badge_text":"","navigation":{"web":{"isMobile":false}}},"version":"10.32.0","moduleName":"navi","bundleName":"navi-inline-retrovision.bundle.js","nonce":{"script":"d5951f1b7cde348759b0310ef405830a"}},"darwin":{"mono":{"homepage_version":"b","homepage_enable_criticalCss":true,"homepage_section_1":"kc_cc_pl_v1","homepage_section_2":"v1","homepage_section_3":"money","homepage_section_4":"v1","homepage_section_5":"v1","homepage_section_6":"v1","homepage_section_7":"v1","homepage_section_8":"v1","homepage_section_9":"v1"}},"navigation-web":{"darwin":{"coreProduct.scooter_mweb_notificationCenterEnabled":true,"coreProduct.scooter_dweb_navPlacement":"top","coreProduct.scooter_dweb_navCopy":"scooter","mono.tax_navbar_badge_text":"control","coreProduct.scooter_mweb_newNavIconsEnabled":false,"coreProduct.scooter_dweb_myRecsEnabled":false,"coreProduct.scooter_dweb_myRecsBadgeEnabled":false,"coreProduct.scooter_dweb_autoHomeEnabled":false},"platformInfo":{"platform":"Web","osType":null},"nonce":"d5951f1b7cde348759b0310ef405830a"},"ckRawTracker":{"enabled":true,"url":"https:x2Fx2Fcreditkarmacdn-a.akamaihd.netx2Fresx2Fcontentx2Fbundlesx2Fcfwk_raw-tracker-webx2F2.8.1x2Findex.js","hash":"sha384-LIWRux2Fmx2FCPYkQvDBx2B6CsmuSqzmdqkZg5VJavhsyvLG1Ly2iXMcOcy8TnMRV65K0O"},"footer":{"darwin":{"mono.geolocation":"hide"},"version":"4.9.8","moduleName":"footer","bundleName":"footer-retrovision.bundle.js","nonce":"d5951f1b7cde348759b0310ef405830a","location":{"country":"US","continent":"NA","subdivision":"OH","zipCode":"43215"},"domain":"US"},"zipkin":{"enabled":false},"request":{"tokens":{"accessToken":false,"refreshToken":false},"cookieId":"6AA3886FD63D41C9B5E1933E22065C85","params":{},"path":"x2F","fullPath":"https:x2Fx2Fwww.creditkarma.gqx2F","traceId":"3234806a-8570-4eec-bace-c58e2b462102"},"isScooter":false,"geoipData":{"country":"US","continent":"NA","subdivision":"OH","zipCode":"43215"},"nonce":"d5951f1b7cde348759b0310ef405830a","platformInfo":{"platform":"Web","osType":null}}
    }
  };
</script>

I want to replace whole code

My Code :

$cloudflare = '<script data-cfasync="false" src="/cdn-cgi/scripts/5c5dd728/cloudflare-static/email-decode.min.js"></script><script nonce="d5951f1b7cde348759b0310ef405830a">
  window.RETROVISION = {
    "homepage": {
      "__render-farm": {"navi":{"variation":"logged_out","darwin":{"mono.corePages_indexController_transactionAccounts":false,"mono.navigation_web_moneyCenterTab":true,"mono.navigation_web_hideMyRecsBadge":false,"mono.taxhub_enabled":true,"mono.enableCardsInWallet":false,"mono.should_show_ciw_in_nav_cc_dropdown":false,"mono.tax_navbar_inseason":false,"mono.navigation_web_nativeUpsell":"control","mono.tax_hub_holdout":true,"autos.purchase_offers_navi_url_enabled":true,"js.cardsInWallet_holdout":false,"js.navi_voter_roadmap_isEnabled":false,"js.navi_voter_roadmap_text":"Voterx20Roadmap","js.reliefCenter_navbar_badge_text":"control","js.useNewLoginNavi":false,"savings.navbar_enabled":true,"mortgage.l1_link_in_authed_navi":true,"mortgage.l1_link_in_unauthed_navi":true,"savings.checking_be_eligibility_flag_v2":true,"savings.billpay_eligible":true,"mortgage.mweb_navi_new_dashboard_link":"new","coreProduct.dweb_stickyTopEnabled":false,"portals.reliefCenter_isEnabled":true,"portals.tax_nav_redirect_enabled":false,"portals.tax_surface_eligibility_unauth":true,"mono.tax_navbar_badge_text":"control","mono.tax_unauth_navbar_badge_text":"","navigation":{"web":{"isMobile":false}}},"version":"10.32.0","moduleName":"navi","bundleName":"navi-inline-retrovision.bundle.js","nonce":{"script":"d5951f1b7cde348759b0310ef405830a"}},"darwin":{"mono":{"homepage_version":"b","homepage_enable_criticalCss":true,"homepage_section_1":"kc_cc_pl_v1","homepage_section_2":"v1","homepage_section_3":"money","homepage_section_4":"v1","homepage_section_5":"v1","homepage_section_6":"v1","homepage_section_7":"v1","homepage_section_8":"v1","homepage_section_9":"v1"}},"navigation-web":{"darwin":{"coreProduct.scooter_mweb_notificationCenterEnabled":true,"coreProduct.scooter_dweb_navPlacement":"top","coreProduct.scooter_dweb_navCopy":"scooter","mono.tax_navbar_badge_text":"control","coreProduct.scooter_mweb_newNavIconsEnabled":false,"coreProduct.scooter_dweb_myRecsEnabled":false,"coreProduct.scooter_dweb_myRecsBadgeEnabled":false,"coreProduct.scooter_dweb_autoHomeEnabled":false},"platformInfo":{"platform":"Web","osType":null},"nonce":"d5951f1b7cde348759b0310ef405830a"},"ckRawTracker":{"enabled":true,"url":"https:x2Fx2Fcreditkarmacdn-a.akamaihd.netx2Fresx2Fcontentx2Fbundlesx2Fcfwk_raw-tracker-webx2F2.8.1x2Findex.js","hash":"sha384-LIWRux2Fmx2FCPYkQvDBx2B6CsmuSqzmdqkZg5VJavhsyvLG1Ly2iXMcOcy8TnMRV65K0O"},"footer":{"darwin":{"mono.geolocation":"hide"},"version":"4.9.8","moduleName":"footer","bundleName":"footer-retrovision.bundle.js","nonce":"d5951f1b7cde348759b0310ef405830a","location":{"country":"US","continent":"NA","subdivision":"OH","zipCode":"43215"},"domain":"US"},"zipkin":{"enabled":false},"request":{"tokens":{"accessToken":false,"refreshToken":false},"cookieId":"6AA3886FD63D41C9B5E1933E22065C85","params":{},"path":"x2F","fullPath":"https:x2Fx2Fwww.creditkarma.gqx2F","traceId":"3234806a-8570-4eec-bace-c58e2b462102"},"isScooter":false,"geoipData":{"country":"US","continent":"NA","subdivision":"OH","zipCode":"43215"},"nonce":"d5951f1b7cde348759b0310ef405830a","platformInfo":{"platform":"Web","osType":null}}
    }
  };
</script>'
$homepage = file_get_contents("https://www.example.com");
$homepage = str_replace($cloudflare, "hello", $homepage);
echo $homepage;

Is it possible to replace like this?

$homepage = str_replace('<script data-cfasync=***/</script>', "hello", $homepage);

How to understand and solve stripe error?

In my tour.pug main head file this:

extends base
include _reviewCard
block append head
    script(src="https://api.mapbox.com/mapbox-gl-js/v2.6.1/mapbox-gl.js")
    link(href='https://api.mapbox.com/mapbox-gl-js/v2.6.1/mapbox-gl.css' rel='stylesheet')
    script(src='https://js.stripe.com/v3/')
    

In my stripe.js file:

const stripe = Stripe('pk_test_something...')

When I load I get error:

Refused to load the script ‘https://js.stripe.com/v3/’ because it
violates the following Content Security Policy directive: “script-src
https://cdnjs.cloudflare.com https://api.mapbox.com ‘self’ blob:”.
Note that ‘script-src-elem’ was not explicitly set, so ‘script-src’ is
used as a fallback.

After this I get mapbox error too:

Refused to connect to ‘ws://localhost:50364/’ because it violates the
following Content Security Policy directive: “default-src ‘self’
https://*.mapbox.com”. Note that ‘connect-src’ was not explicitly set,
so ‘default-src’ is used as a fallback.

I didnt understand what mean these errors and how to fix these issues. Thanks

Vue3 Multiple Highcharts

I’m new to Vue, and struggling to display multiple Highcarts on a Vue3 page using vue3-highcharts. I followed the Reactive Chart Example here, which works great, but I’m confused how to implement the chartOptions object for multiple charts using v-for.

A single chart using the following code works:

<vue-highcharts
    type="chart"
    :options="chartOptions"
    :redraw-on-update="true"
    :one-to-one-update="false"
    :animate-on-update="true"
    @updated="onUpdate"/>

and the associated setup / computed code

setup() {
          const seriesData = ref([25, 39, 30, 15]);
          const categories = ref(['Jun', 'Jul', 'Aug', 'Sept']);
    
          const chartOptions = computed(() => ({
            chart: {
              type: 'line',
            },
            title: {
              text: 'Number of project stars',
            },
            xAxis: {
              categories: categories.value,
            },
            yAxis: {
              title: {
                text: 'Number of stars',
              },
            },
            series: [{
              name: 'New project stars',
              data: seriesData.value,
            }],
          }));

I have tried multiple methods to use v-for to load multiple charts, here is the latest / most successful:

<vue-highcharts
  v-for="item in hmCharts"
  :key="item.id"
  :options="item.options"
  :redraw-on-update="true"
  :one-to-one-update="false"
  :animate-on-update="true"
  @rendered="onRender"
  @update="onUpdate"
  @destroy="onDestroy" />
  

const hmCharts = ref([
      {
        id: 'one',
        options: getChartoptions('one')
      },{
        id: 'two',
        options: getChartoptions('two')
      }])

 const seriesData  = [[0, 0, 10], [0, 1, 19], [0, 2, 8], [0, 3, 24], [0, 4, 67], [1, 0, 92], [1, 1, 58], [1, 2, 78], [1, 3, 117], [1, 4, 48], [2, 0, 35], [2, 1, 15], [2, 2, 123], [2, 3, 64], [2, 4, 52], [3, 0, 72], [3, 1, 132], [3, 2, 114], [3, 3, 19], [3, 4, 16], [4, 0, 38], [4, 1, 5], [4, 2, 8], [4, 3, 117]] 

    hmCharts.value[0].options.series[0].data = seriesData
    hmCharts.value[1].options.series[0].data = seriesData

This method will eventually load both charts, but it takes a full minute or more to load. I found the following error in the console:

runtime-core.esm-bundler.js?9e79:6620 [Vue warn]: Maximum recursive
updates exceeded. This means you have a reactive effect that is
mutating its own dependencies and thus recursively triggering itself.
Possible sources include component template, render function, updated
hook or watcher source function.

I have spent more time and research on this than I care to admit, and really hoping someone can help me understand what it happening here. Thanks!

How would I go about splitting a string into characters – Javascript

I want to split a string, such as this:

"Hello %id:1%, how are you %id:2% etc...",

but “%id:Int%” should not be split:

const test = [
  "%id:1%",
  "%id:2%",
  "%id:3%"
]

let str = "test %id:1%!";
str = str.split("");
// wanted result: ["t", "e", "s", "t", " ", "%id:1%", "!"]; 
// actual result: ["t", "e", "s", "t", " ", "%", "i", "d", ":", "1", "%", "!"]

This would take anything from the “test” array and not split it with every sepparate character.

is there a way to target each image from the array individually in order to make them highlight when clicked?

I’m trying to get the logos highlighted some way whenever a user has clicked on them so they will know exactly on which card they are actively on. I have no clue how to do this. any suggestions will be incredibly appreciated!



const professions = [
 {
   circular: <CircularProgressbar value= "99" text={`99%`} 
   styles={buildStyles({
    // Whether to use rounded or flat corners on the ends - can use 'butt' or 'round'
    strokeLinecap: 'butt',
    // Text size
    textSize: '16px',
    // How long animation takes to go from one percentage to another, in seconds
    pathTransitionDuration: 1.5,
    // Colors
    pathColor: `rgba(16, 38, 71, ${99 / 100})`,
    textColor: '#102647',
    trailColor: '#e0e0eb',
    backgroundColor: '#3e98c7',
  })}
  /> ,
   git:<FaGitAlt/>,
   industrycon: <IoRocketSharp alt="Space Rocket"/> ,
   key: "card1",
   project:"SAFE ZONE",
   icon: <FaRegEye alt="ComNatural Language processing-logo" />,
   percentage: 99,
   specialty: "CV - DATA ANALYTICS ",
   industry:" Gases Clinicos",
   summary:"Compliance del 99% de normas sanitarias para operación en pandemia , identifiacando dist. social, aforo y mascarilla.",
   logo: <img className="logus Mediumsquare" src={imgrep(1)} alt="altofem" />
 },


 { 
   circular: <CircularProgressbar value= "40" text={`40%`} 
   styles={buildStyles({
    // Whether to use rounded or flat corners on the ends - can use 'butt' or 'round'
    strokeLinecap: 'butt',
    // Text size
    textSize: '16px',
    // How long animation takes to go from one percentage to another, in seconds
    pathTransitionDuration: 1.5,
    // Colors
    pathColor: `rgba(16, 38, 71, ${40 / 100})`,
    textColor: '#102647',
    trailColor: '#e0e0eb',
    backgroundColor: '#3e98c7',
  })}
  /> ,
   key: "card2",
   industrycon: <IoRocketSharp alt="Space Rocket"/>,
   git:<FaGitAlt/>,
   project:"Automatización EEPP-forecasting",
   icon: <GiProcessor alt="Natural Language processing-logo"/>,
   specialty: "NLP- Data analytics ",
   industry: "Constructora Inmobiliaria",
   summary: "Automatización en estados de pago con NLP",
   logo: <img className="logus Biground" src={imgrep(2)} alt="vimac" />,
 },


 {
   circular: <CircularProgressbar value= "96" text={`96%`} 
   styles={buildStyles({
    // Whether to use rounded or flat corners on the ends - can use 'butt' or 'round'
    strokeLinecap: 'butt',
    // Text size
    textSize: '16px',
    // How long animation takes to go from one nother, in seconds
    pathTransitionDuration: 1.5,
    // Colors
    pathColor: `rgba(16, 38, 71, ${96 / 100})`,
    textColor: '#102647',
    trailColor: '#e0e0eb',
    backgroundColor: '#3e98c7',
  })}
  /> ,
   key: "card3",
   industrycon: <IoRocketSharp alt="Space Rocket"/>,
   git:<FaGitAlt/>,
   project:"Diagnoticos de CV",
   icon:<BsFileEarmarkText alt="Text Icon"/> ,
   specialty: "NLP",
   industry: "Recursos Humanos",
   summary:"Un Ahorro del 96% del tiempo total gastado en diagnósticos de CV",
   logo: <img  className="logus Mediumsquare" src={imgrep(3)} alt="peopleparnerts" />,
 }
];

const [myProfession, setMyProfession] = useState("");
const[seeF, setSeef]= useState(true);
const[stepOn, setStepOn]= useState(false);


//function to set showf to false, so it wont be rederized
function showF(){
 if(seeF)
 {
  setSeef(false)
  setStepOn(true)
 }
}

//function to target the logos
function light(){
console.log("clicked");  
}

return (

  <>
   {/* INFORMATION CARDS */}
   <Container> 
     <LeftSide>
       <Bottom>
        {seeF ? <FrontCard/> : null}
         {(professions) && (
       <Cards 
       circular={myProfession.circular}
       project={myProfession.project}
       icon={myProfession.icon}
       percentage={myProfession.percentage} 
       specialty= {myProfession.specialty}
       industry={myProfession.industry}
       summary={myProfession.summary}
       git={myProfession.git}
       industrycon={myProfession.industrycon}
        />       
         )}    
         
         {professions.map((profession) => ( 
           <info
           circular={profession.circular}
           project={profession.project}
           icon={profession.icon}
           git={profession.git}
           industrycon={profession.industrycon}
           percentage={profession.percentage}
           specialty={profession.specialty}
           industry={profession.industry}
           summary={profession.summary}
           className={profession.logo.props.className}
           src={profession.logo.props.src}
           onMouseEnter={() => setMyProfession(profession.logo.props.alt)}/>
         ))}
       </Bottom>
     </LeftSide>
     {/* HOVERING LOGOS */}
     <RightSide onClick= {()=> showF()}>
       <h2> Nuestros Casos de Exito </h2>
       <br />
       <Buttons>
         {professions.map((profession) => (
           <>
             <img 
               type="img"
               key={profession}
               id={profession.logo.props.id}
               src={profession.logo.props.src}
               className={profession.logo.props.className}
               onClick={() => {setMyProfession(profession); light();}}
             ></img>
           </>
         ))}
       </Buttons>
     </RightSide>
   </Container>
 </>
);
};

export default ShowAndHide;


this is how it looks right now, but nobody is able to tell which company’s info is rendered right now

enter image description here

How to convert column of currency to number using Javascript/D3? [duplicate]

After reading in data from a csv, I have an array of objects like so,

myData = [
    {country: "USA", amount: " $1,000,000.00"},
    {country: "Canada", amount: " 1,500,000.00"},
    {country: "Mexico", amount: " $2,000,000" }
]

I am trying to create a variable called total that sums up the “amount” column. However, there is leading white space and the dollar signs (essentially it is being interpreted as a string).

Is there a way to convert the amount column to a number so that it can be summed?

node : The term ‘node’ is not recognized as the name of a cmdlet, function, script file, or operable program

I’ve tried looking at a lot of resolutions for this same issue but none seem to work. I still cannot get Visual Studio Code to recognize Node. I have it installed and the path included in my system variables, I have uninstalled and reinstalled vs code, restarted my computer, and tried virtually everything else but I get the same error. It’s weird cause I tried this on my other computer and it worked just fine. Any ideas on how to resolve this??
Error

Path

Is it possible to auto scroll a website and select items in a list?

Before I spend too much time researching this I though I would ask the question here to make sure that it is even possible what I am trying to do.

Context: I am trying to help a friend who is a truck driver. He uses a dispatch website to select his freights. The website lists everything that is available as a list but it does not let him filter by zip code. Basically he has to manually scroll this big list looking for deliveries. If he finds something on his zip code or around it he selects it.

Question: Is it possible to auto-scroll the website, filter by zip code and select an item, if it matches?

There are no available APIs that would allow me to do this programmatically. So I though maybe there is a way to scroll the website using JavaScript and select base on a particular field (zip code).

Is this even possible? Is there a better way to go about this?

Thank you for any help.

Multiple and different conditions in Javascript

I have a problem with logic.
If the number is higher than 0 and less than 10 AND the number is 11 AND the number is 22 do something. (1, 2, 3, 4, 5, 6, 7, 8, 9, 11 or 22).

And ELSE IF the number is higher than 10 BUT is NOT 11 or is NOT 22, do something else. (10, 12, 13 ….20, 21, 23, 24…)

I got to do only with 11, but I have no clue how to insert another condition with 22.

if (n >= 0 && n < 10) || (n == 11 && n == 22) {
        do something

    } else if (n >= 10 && n != 11) && (n != 22) {
        do something else
    }

Please, don’t downvote. English is not my first language.

Nodejs app suddenly started to act differently

This part of code handles the login authorization routing in my app

const express = require("express");
const authController = require('../controllers/authController');
const indexController = require('../controllers/indexController');
const router = express.Router();

router.use("/login", (req, res, next) => {
  if(req.session.loggedIn) {
    res.redirect('/account');
  }
  next();
});

router.use("/account", (req, res, next) => {
  if(!req.session.loggedIn) {
    res.redirect('/login');
  }
  next();
});

router.get('/', (req, res) => {
  res.redirect('/login');
});
router.get('/login', (req, res) => {
  res.render('login');
});
router.get('/log-out', authController.logOut);
router.get("/account", indexController.getAccountData);

module.exports = router;

There were no problems and it was working fine till recent days.

I haven’t change anything in this file nor authController nor indexController.
When I make a change (in other parts), nodemon restarts the app and I automatically jump to login page cause obviously all sessions are destroyed. But I get an error in getAccountData function (Error says req.session is undefined).

As you can see there’s no way for the app to reach that function with no sessions set.

I have to restart the app again to act correct.