My bcrypt.js hash returns null while all other inputs are fine

This code below returns the input password as null, but all other inputs are fine. I don’t know what to do, if anyone can help please do.

I am using bcrypt with knex for psql.

app.post("/register", (req, res) => {
  const { email, name, password } = req.body;
  let salt = bcrypt.genSaltSync(10);
  let hash = bcrypt.hashSync(password, salt);
  
  knex
    .transaction((trx) => {
      trx
        .insert({
          hash: hash,
          email: email,
        })
        .into("login")
        .returning("email")
        .then((loginEmail) => {
          return trx("users")
            .returning("*")
            .insert({
              email: loginEmail[0].email,
              name: name,
              joined: new Date(),
            })
            .then((user) => {
              res.json(user[0]);
            });
        })
        .then(trx.commit)
        .catch(trx.rollback);
    })
    .catch((err) => res.status(400).json("E-mail is already in use"));
});

Having some issues with Edge. Would like to ask a couple basic questions

Opened 2 tabs on Edge and then another popped up that wanted me to verify through authentication without me doing anything that would call it to prompt. A little suspicious. Opened up Visual Studio 2022 to debug the authorization window that would not go away. I find that there is actually 7 instances of Webview, 6 instances of Windows.Client.WebExperience, and 11 general processes for Microsoft Edge (with no specific title). There is also an additional window that has the name of a window title attributed to it. Looking at the type of file, all of the Edge processes are listed as 64-bit, Javascript. Should I assume that there are several hidden Edge windows each running javascript?

Upon choosing a random windows, debugging fails with error message “Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:9222” Why is visual studio trying to connect as a remote debugger through a TCP port?

All the connections for all of these processes have destinations listed as * in Sysinternals TCPView. I went to try wireshark and netstat. Some time while running those, I went back to TCPView and all the process IDs had changed to the same PID, even though I know they each had a unique PID before. How would a program be able to do this? What would be a foolproof way to track my destination IP address should this happen again?

How to make a template css can be call with specific condition?

I design start layout with width 320px, my target is mobile device first > tablet > desktop. I check in developer mode in chrome, iphone 6/7/8 give me different result whereas iphone 6/7/8 still a mobile device, same as galaxy s4. what i need to set same setting by type device?

<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
      body { margin: 0; }
      .container {
        width: 100%;
        height: 20px;
        background-color: gray;
      }
      
      .container > div {
        width: 320px;
        height: inherit;
        background-color: pink;
        margin: auto;
        font-size: 1em;
      }
    </style>
  </head>
  <body>
    <div class="container">
      <div>
        Responsive By Type Devices
      </div>
    </div>
  </body>
</html>

grid-template-columns – items not in center

I am trying to create my own grid using “grid-template-columns”, in result when i resize the view items not centered.

I use this documentation https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns

I am stuck and need some advice, what i am doing wrong.

P.S In normal desktop view looks ok, but in mobile …
Below i attached screenshot and my code example.

enter image description here

Here code example what i am using:

<!DOCTYPE html>
<html lang="en">
    
    <head>
        <meta charset="utf-8">
        <title>Profile Card</title>
        <link rel="stylesheet" href="css/font-awesome.min.css">       
        <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,600,700' rel='stylesheet'>
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
        <link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css" integrity="sha384-AYmEC3Yw5cVb3ZcuHtOA93w35dYTsvhLPVnYs9eStHfGJvOvKxVfELGroGkvsg+p" crossorigin="anonymous"/>
        <style>

.my-grid {
    display: flex;
    justify-content: center;
    align-content: center;
}

.my-container{
    position: relative;
    width: 1200px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    grid-gap: 20px;
    padding: 20px;
}

.my-container .my-card{
    width: 100%;
    background: #fff;
    border-radius: 20px;
    max-width: 250px;
    box-shadow: 0px 20px 70px 0px rgb(0 0 0 / 21%);
}

.my-container .my-card .imgBx {
    position: relative;
    width: 100%;
    height: 310px;
    overflow: hidden;
}

.my-container .my-card .imgBx img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: 0.5s ease-in-out;
    transform-origin: right;
}

.my-container .my-card:hover .imgBx img {
    transform: scale(1.5);
}

.my-container .my-card .my-content{
    padding: 10px;
}

.my-container .my-card .my-content .my-product-name h3{
    font-size: 18px;
    font-weight: 500;
    color: #333;
    margin: 5px 0;
    text-align: center;
}

.my-container .my-card .my-content .my-rating {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: center;
    padding: 15px;
}

.my-container .my-card .my-content .my-rating h2{
    font-size: 20px;
    color: #333;
    font-weight: 500;
}

.my-action{
    position: absolute;
    top: 10px;
    right: 10px;
}

.my-action li{
    position: relative;
    list-style: none;
    width: 40px;
    height: 40px;
    background: #fff;
    border-radius: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 4px;
    cursor: pointer;
    transition: transform 0.5s;
    transform: translateX(60px);
}

.my-action li:nth-child(2){
    transition-delay: 0.15s;
}

.my-action li:nth-child(3){
    transition-delay: 0.3s;
}

.my-container .my-card:hover .my-action li{
    transform: translateX(0px);
}

.my-action li:hover{
    background: #a7389d;
    color: #fff;
}

.my-action li span{
    position: absolute;
    right: 50px;
    top: 50%;
    transform: translateY(-50%) translateX(-20px);
    white-space: nowrap;
    padding: 4px 60px;
    background: #fff;
    color: #333;
    font-weight: 500;
    font-size: 12px;
    border-radius: 4px;
    pointer-events: none;
    opacity: 0;
    transition: 0.5s;
}

.my-action li:hover span{
    opacity: 1;
    transform: translateY(-50%) translateX(0px);
}

.my-action li span::before{
    content: ' ';
    position: absolute;
    top: 50%;
    right: -4px;
    width: 8px;
    height: 8px;
    background: #a7389d;
    transform: translateY(-50%) rotate(50deg);
}

.app{
    text-align: center;
}

.app h6{
    display: inline-block;
}

.verified-label{
    text-align: center;
}

.verified-label h6{
    display: inline-block;
}

</style>
    </head>

    <body>



<div class="my-grid">
<div class="my-container">

    <div class="my-card">
        <div class="imgBx">
            <img src="/test.jpg">
            <ul class="my-action">
                <li>
                    <i class="fas fa-external-link-alt"></i>
                    <span>View more</span>          
                </li>
                <li>
                    <i class="fas fa-camera"></i>
                    <span>2</span>          
                </li>
                <li>
                    <div class="f32">
                        <a class="flag ru"></a>
                   </div>           
                </li>
            </ul>
        </div>
        <div class="my-content">
            <div class="my-product-name">
                <h3>Test Name</h3>
            </div>
            <div class="app">
                <span class="fas fa-mobile-alt">
                        <h6></h6>
                </span>
            </div>
            <div class="verified-label">
                <span class="fas fa-gem">
                        <h6></h6>
                </span>
            </div>
            <div class="my-rating">
                <div class="rating">
                    <i class="fas fa-fire"></i>
                    <h2>168</h2>
                </div>
                <div class="rating">
                    <i class="fas fa-eye"></i>
                    <h2>168</h2>
                </div>
                <div class="rating">
                    <i class="fas fa-heart"></i>
                    <h2>168</h2>
                </div>
            </div>
        </div>
    </div>
    
        <div class="my-card">
        <div class="imgBx">
            <img src="/test.jpg">
        </div>
        <div class="my-content">
            <div class="my-product-name">
                <h3>Test Name</h3>
            </div>
            <div class="my-rating">
                <div class="rating">
                    <i class="fas fa-fire"></i>
                    <h2>168</h2>
                </div>
                <div class="rating">
                    <i class="fas fa-eye"></i>
                    <h2>168</h2>
                </div>
                <div class="rating">
                    <i class="fas fa-heart"></i>
                    <h2>168</h2>
                </div>
            </div>
        </div>
    </div>
    

</div>
</div>
        <script src="js/jquery-1.12.1.min.js"></script>
        <script src="js/pCard_script.js"></script>
        <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"></script>

    </body>
    
</html>

I am stuck, pls advice =(

Train Time Table

  1. The display should show a clock, so people know what time it is.
  2. The display should show the next two buses due to leave the station
  3. The display should show a minute-by-minute update on when the buses
    are due to depart
  4. The display should indicate when no buses are due to depart in the
    next 15 minutes
  5. Every minute on the timetable should be represented in real-time
    seconds (i.e. 1 hour = 60 seconds)

In React / JavaScript

Looking to identify if a member has Timeout on

So with Discord releasing member timeout, mute roles are no longer a necessity, however with my whois command I check to see if the user is muted with a mute role but I want to move that over to see if the user has a timeout on them

    const { MessageEmbed } = require('discord.js')

module.exports = {
  name: 'whois',
  description: 'Displays Information about a user',
  async execute(client, message, cmd, args, Discord){
    const { guild, channel } = message;
    const user = message.mentions.users.first() || message.author;
    const member = message.guild.members.cache.get(user.id);
    let muteRole = message.member.roles.cache.some(role => role.name === 'muted')
    if(!muteRole) muteRole = message.member.roles.cache.some(role => role.name === 'Muted');

    const userInfoEmbed = new MessageEmbed()
    .setColor("BLACK")
    .setTitle(`User Info for ${user.username}`)
    .setThumbnail(`${user.displayAvatarURL()}`)
    .addFields(
      { name: 'User Tag:', value: `${user.tag}` },
      { name: 'Online Status:', value: `${member.clientStatus}` },
    { name: 'Nickname:', value: member.nickname || 'N/A' },
   { name: 'Bot:', value: `${user.bot}` , inline: true },
   { name: 'Joined on:', value: new Date(member.joinedTimestamp).toLocaleDateString() , inline: true },
   { name: 'Created on:', value: new Date(user.createdTimestamp).toLocaleDateString() , inline: true },
   { name: 'Bannable:', value: `${member.bannable}` , inline: true },
   { name: 'Highest Role:', value: `${member.roles.highest}`, inline: true },
  // { name: 'Muted:', value: `${muteRole}`, inline: true},
 )
 .setFooter(`Requested by ${message.author.username}`)
 .setTimestamp()


message.channel.send({ embeds: [userInfoEmbed] })

  }
}

Mongodb Or query with two arrays

I am trying to perform an or query in MongoDB.

I have two array

firstNames = ['John', 'Tim','Joey']
lastNames = ['Alex', 'Smith', 'Mac']

I want to perform a query like

{$or: [{firstName: 'John', lastName: 'Alex'}, {firstName: 'John', lastName: 'Smith'}, {firstName: 'John', lastName: 'Mac'}, {firstName: 'Tim', lastName: 'Alex'} ... ]}

I tried

1.

Users.find({firstName: {$in: firstNames}, lastName: {$in: lastNames} })
Users.find({$or:[{firstName: {$in: firstNames}}, {lastName: {$in: lastNames} }]})

but this is wrong I guess. Can someone provide a better solution to this?

How can you get more than one $or condition into a single mongodb find() operation?

I’ve got an operation where I’m trying to limit results on a collection using the $or operator, however I have more than one field that needs to utilize this functionality.

See query below:

db.items.find({//"isDeleted":false,
    "$or":[
        {"$and":[{"passages.fleschKincaid.readingEase":{"$gte":90}}]},
        {"$and":[{"passages.fleschKincaid.readingEase":{"$gte":60}},{"passages.fleschKincaid.readingEase":{"$lte":70}}]},
        {"$and":[{"passages.fleschKincaid.readingEase":{"$gte":50}},{"passages.fleschKincaid.readingEase":{"$lte":60}}]}
    ],
    "$or":[{"$and": [{"contentBanks":{$in: element.statusIds}}]}]})

The first condition loops through and adds on gte/lte operators based on certain conditions, and the second or condition I’ve used here is within a for loop that pushes on an additional $and for each new contentBank. Each one only needs to satisfy one of the conditions to show as a result, but contentBank and passages.fleschKincaid.readingEase are mutually exclusive so they can’t be grouped together in the same $or group.

i.e. – if I have an item, for it to meet my conditions in the above example, it needs both a readingEase score of let’s say 55, AND have a contentBank in statusIds. It needs to meet both conditions, but check the $or‘s separately.

What I end up with is a query that overwrites the written conditions and treats it as one big $or, returning results that might match one contentBank but not be within the readingEase range.

Any help would be greatly appreciated. I’m writing this with javascript, mongoose, and mongodb. If you know of a way to get the query to treat them separately that would be great.

p.s. – I’m trying to avoid it getting to chock-full of $and operators, but if that’s the only way to do this, I can find a way to create a whole new object and add it in. The only issue with that is the complexity increases quite a bit because the pipeline operators are all built dynamically – so the additional $and operator wrapping everything would require a solid amount of changes/overhead to get working.

Regex testing a string with uppercase letters, lowercase letters, numbers, special symbols, with no whitespace

I’m trying to evaluate a js string with a regex function that will detect the above mentioned criterias except for the symbols part, as I only need to evaluate if dots or underscores are in the string. An example is this:

mfv.3djtSewe5jCrg19A_fkdrOe8LG2zL7cY1oK4lEN5m3z6jh9bvpUlnxfP4qdbAwhuUruN_uKRv6trcROqXm4P

and the regex I’m using is this:

/^(?!.*s+$)(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[_.]).+$/

I’m new to javascript let alone regex matching and I’m not entirely sure how to do this.

Trouble splitting a string in JavaScript using regular expressions

I am VERY new to regex in js and having a very hard time manipulating them to do what I am looking for.

I have a series of strings that I am trying to strip of unusual characters, spaces, newlines, etc. and put them into arrays where each entry is a word consisting of only alphanumeric characters.

For example:

let testString = "this*is " + "an" +" test string "
test = testString.split(/W/)  
console.log(test)

Yields [ 'this', 'is', 'a', '', 'test', 'string', '' ]

But ideally I would like it to yield [ 'this', 'is', 'a', 'test', 'string']

I can achieve the desired result by adding .filter(word => word !== '') to the end, but I am wondering if there is a way to do this using only regular expressions? Also would it be necessary to add a global flag to the regex?

Thanks in advance for any input!

Angular service not updating component html element

I have a property in an object in an Angular service that is bound to a text field in a component’s html.

When the property is updated by the service, the new value is not showing in the html element until I click on the element.

I cannot figure out why the new value isn’t immediately showing in the text field without having to click on the element to get the new value.

The console.log message in the update function shows that the object is updated correctly, it’s just that the data is not making it through to the form field until the element is clicked.

The code is below:

parent.component.html

<input [(ngModel)]="service.selectedMarker.data" type="text" />

service.service.ts

public serviceObj = {} as any;

...

updateObj() {
    this.serviceObj.data = 'new value';
    console.log('this.serviceObj = ', this.serviceObj);
}

...

How to do in right way small React JS App [closed]

There is an app, like Scrum game

enter image description here

every developer can select card with task difficulty estimation and unveil it for another devs in Scrum room.

FrontEnd Apps communicate with each other with backend Node.js script via WebSocket.

FrontEnd App is built with jQuery and it works well.

I was tasked to rebuild it with React JS.
I started with cards and stacked almost immediately.

Question is how to build App architecture to not use huge and deep global state but use component dependent states?

My approach :

class scrumPoker {

constructor() {

    this.selfCardStates = [
        { n : 1, value : 0, state : 'inactive' },
        { n : 2, value : 1, state : 'inactive' },
        { n : 3, value : 10, state : 'inactive' },
        { n : 4, value : 50, state : 'inactive' },
    ];
    this.cardRefs = [];
    this.selfCardStates.map( ( card, i ) => {
        this.cardRefs[i] = useRef( null );
    } );
    this.tools = toolBox = new toolBoxClass();

}

renderSingleCard = ( cardState ) => {

    const [ card, setCard ] = useState( cardState );
    const state = ( card.state == 'inactive' ) ? 'active' : 'unveiled';

    return (
        <div key={card.n} ref={this.cardRefs[card.n]} className="single-card"
             onClick={ () => {
                setCard( { n: card.n, value: card.value, state: state } );
                this.cardRefs[card.n].current.className = 'single-card ' + state;
             } }>
            <div className="card-n">{card.n}</div>
            <div className="card-value">{card.value}</div>
            <div className="card-state">{card.state}</div>
        </div>
    );

}

renderCards = () => {

    let cards = [];
    cards = this.selfCardStates.map( ( cardState, i ) => {
        return this.renderSingleCard( cardState, i )
    } );

    return (
        <div className="cards-box">{cards}</div>
    );

}

renderMainPage = function() {
    return (
        <React.Fragment>
            <this.renderCards />
            <div className="test-box">
                <button onClick = { () => {
                    this.selfCardStates = [
                        { n : 4, value : 20, state : 'active' },
                        { n : 3, value : 30, state : 'active' },
                        { n : 2, value : 50, state : 'active' },
                        { n : 1, value : 100, state : 'active' },
                    ];
                } }>test</button>
            </div>
        </React.Fragment>
    );
}

}

I expect to update state of all of 4 cards by button click, so I expect to see new cards set, but nothing happens.

cardRefs is used for CSS manipulating, it is secondary stuff.

Where is the convenience of React JS and how to re-build class to have ability to rebuild Cards set in reactive way by button click ( or Websocket answer receiving in real App ) ?

I do not understand how to organize my App to have flexibility with states manipulation and not to build large deep-nested almost global State ?

In terms of this App it means will be added another modules ( to create room, to handle WS requests, to add / remove user etc. ) and I do not see how to complete it without large deep-nested State.

How to structure App in right way ?

404 on create_intent via solidus_stripe gem

Trying to integrate v3 intents , followed the readme but i keep getting thoses errors on js side :

Feature Policy: Skipping unsupported feature name “payment”. v3:1:78187
Feature Policy: Skipping unsupported feature name “payment”. v3:1:78325
Feature Policy: Skipping unsupported feature name “payment”. v3:1:178554

and when i submit the test card informations :

POSThttps://_my_web_site_url.com/stripe/create_intent [HTTP/1.1 404 Not Found 897ms]

I keep searching for what kind of integration error i could’ve done but nothing , i have the feeling it lack a memeber of the posting url
all mentions in stripe’s doc are specifying a version in them .

i’am running

rails 5.2.6 on ruby 2.7 with:
solidus (2.10.5)
solidus_api (= 2.10.5)
solidus_backend (= 2.10.5)
solidus_core (= 2.10.5)
solidus_frontend (= 2.10.5)
solidus_sample (= 2.10.5)
solidus_api (2.10.5)
solidus_stripe (4.2.0)


config.static_model_preferences.add(
Spree::PaymentMethod::StripeCreditCard,
'stripe_env_credentials',
secret_key:'sk_test_aksdhflkajsgdflkuasgdf',
publishable_key: 'pk_test_kjhga;lihglkashglasd',
stripe_country: 'FR',
v3_elements: false,
v3_intents: true,
)

And the stripe static conf has been selected in the backend’s payment page .

THanks in advance for reading / helping .

On page load Accordion tab open

I am working with a WordPress site and I am using an accordion addon. I would like for the first accordion tab to be open when a user loads the page. How/where can I do that? Is it in the backend of the site somewhere?

Also, do I need to be using javascript or jquery for this?

Thanks!

Cannot read property of undefined (reading ‘remove’) after appending child in ul

I don’t know what is wrong with this code. When I append app child to the tag and when I try to click the delete button of the appended child it shows me this error.

if you have a solution then provide me or give me suggestion to do this task

Cannot read properties of undefined (reading ‘remove’).

You can check the code as well.

HTML Code.

<!DOCTYPE html>
<html>
  <head>
    <title>Javascript + DOM</title>
    <link rel="stylesheet" type="text/css" href="style.css" />
  </head>
  <body>
    <h1>Shopping List</h1>
    <p id="first">Get it done today</p>
    <input id="userinput" type="text" placeholder="enter items" />
    <button id="enter">Enter</button>
    <ul>
      <li class="bold red" random="23">
        Notebook <button class="deleteButton">Delete</button>
      </li>
      <li>Jello <button class="deleteButton">Delete</button></li>
      <li>Spinach <button class="deleteButton">Delete</button></li>
      <li>Rice <button class="deleteButton">Delete</button></li>
      <li>Birthday Cake <button class="deleteButton">Delete</button></li>
      <li>Candles <button class="deleteButton">Delete</button></li>
    </ul>
    <script type="text/javascript" src="script.js"></script>
  </body>
</html>

JavaScript Code.

var button = document.getElementById("enter");
var input = document.getElementById("userinput");
var ul = document.querySelector("ul");
var li = document.querySelector("li");
var deleteButton = document.getElementsByClassName("deleteButton");
var liAll = document.querySelectorAll("li");

function inputLength() {
  return input.value.length;
}

function createListElement() {
  var li = document.createElement("li");
  li.appendChild(document.createTextNode(input.value));

  const returnedLi = createDeleteButtonElement(li);

  ul.appendChild(returnedLi);
  input.value = "";
  strikeThroughOnClick();
  deleteOnClick();
}

function createDeleteButtonElement(li) {
  var button = document.createElement("button");
  button.appendChild(document.createTextNode("Delete"));
  button.classList.add("deleteButton");
  li.appendChild(button);
  return li;
}

function addListAfterClick() {
  if (inputLength() > 0) {
    createListElement();
  }
}

function addListAfterKeypress(event) {
  if (inputLength() > 0 && event.keyCode === 13) {
    createListElement();
  }
}

function strikeThrough(i) {
  liAll[i].classList.contains("done")
    ? liAll[i].classList.remove("done")
    : liAll[i].classList.add("done");
}

function deleteItem(i) {
  //   console.log();
  liAll[i].remove();
  //   this.parentNode.remove();
}

function deleteOnClick() {
  for (let i = 0; i < deleteButton.length; i++) {
    deleteButton[i].addEventListener("click", () => deleteItem(i));
  }
  return deleteButton;
}

function strikeThroughOnClick() {
  for (let i = 0; i < liAll.length; i++) {
    liAll[i].addEventListener("click", () => strikeThrough(i));
  }
  return liAll;
}

button.addEventListener("click", addListAfterClick);

input.addEventListener("keypress", addListAfterKeypress);

strikeThroughOnClick();
deleteOnClick();