Recharge App returning error Variant can only be purchased with a selling plan

In my Shopify Store when I uncheck the option “Only show this product with these purchase options” via Product Admin the add to cart button return the error Variant can only be purchased with a selling plan..

I’m using Recharge App as a subscription App. I already tried to add <div class="rc-widget-injection-parent" style="display: initial;"></div> the peace of code they suggested but that’s not the problem.

I’ve check my cart data and the selling_plan with the id is there.

The way I’m passing this data to cart is:

Anyone have faced this issue? Recharge says to check the data in the cart but that seems to be the correct one:

form_type: "product"
id: "31435799056334926"
quantity: "1"
selling_plan: "68812544433453485"
selling_plan_1501630: "subsave"
utf8: "✓"

rxjs/angular how to convert http response to array-like object

need to convert a json response body into a array-like object in an Angular 13 environment

the incoming response data looks like:

 [
    {
      "n": 1,
      "s": "s1"
    },
    {
      "n": 2,
      "s": "s2"
    },
    {
      "n": 3,
      "s": "s3"
    }
  ]

the resulting array-like object needs to look like

{
   numArray: [1,2,3],
  stringArray: ['s1','s2','s3']
}

have tried using map, flatmap, toArray + others from RxJS library seem to be unable to make the list. generally end up with:

{n: 1, s: 's1'}
{n: 2, s: 's2'}
{n: 3, s: 's3'}

how to do this translation?

Errors of these types : Cannot find name ‘XYZ ‘. and Property ‘XYZ’ does not exist on type ‘{}’

Typescript 4.5.5
NodeJS 14

This is my first ever question here. after a whole day i am at my wits end, cannot figure out what’s wrong, tried so many things then posted here.

  • Property ‘video‘ does not exist on type ‘{}’.ts(2339) in data.video
  • Property ‘title‘ does not exist on type ‘{}’.ts(2339) in data.title
  • Property ‘desc‘ does not exist on type ‘{}’.ts(2339) in data.desc
    you get the idea.
export default function Upload() {
  const [title, setTitle] = useState<string>('')
  const [description, setDescription] = useState<string>('')
  const [category, setCategory] = useState<string>('')
  const [location, setLocation] = useState<string>('')
  const [thumbnail, setThumbnail] = useState<File>()
  const [uploadData, setUploadData] = useState({})
  const [video, setVideo] = useState<File>()

  const thumbnailRef = useRef<HTMLInputElement>(null)

  const { mutate: createAsset, data: asset, uploadProgress } = useCreateAsset()



  const goBack = () => {
    window.history.back()
  }

  // When a user clicks on the upload button
  const handleSubmit = async () => {
    // Calling the upload video function
    await uploadVideo()
    // Calling the upload thumbnail function and getting the CID
    const thumbnailCID = await uploadThumbnail()
    // Creating a object to store the metadata
    let data = {
      video: asset?.id,
      title,
      description,
      location,
      category,
      thumbnail: thumbnailCID,
      UploadedDate: Date.now(),
    }
    // Calling the saveVideo function and passing the metadata object
    console.log(data)
    await saveVideo(data)
  }

  // Function to upload the video to IPFS
  const uploadThumbnail = async () => {
    // Passing the file to the saveToIPFS function and getting the CID
    const cid = await saveToIPFS(thumbnail)
    // Returning the CID
    return cid
  }

  // Function to upload the video to Livepeer
  const uploadVideo = async () => {
    // Calling the createAsset function from the useCreateAsset hook to upload the video
    createAsset({
      name: title,
      file: video,
    })
  }

  // Function to save the video to the Contract
  const saveVideo = async (data = uploadData) => {
    // Get the contract from the getContract function
    let contract = await getContract()
    // Upload the video to the contract

    await contract.uploadVideo(
      data.**video**,
      data.**title**,
      data.**description**,
      data.**location**,
      data.**category**,
      data.**thumbnail**,
      false,
      data.**UploadedDate**
    )
  }

This is the schema.ts of graphprotocol. it was automatically generated but its getting errors when npm run build

// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.

import {
  TypedMap,
  Entity,
  Value,
  ValueKind,
  store,
  Bytes,
  BigInt,
  BigDecimal
} from "@graphprotocol/graph-ts";

export class Video extends Entity {
  constructor(id: string) {
    super();
    this.set("id", Value.fromString(id));
  }

  save(): void {
    let id = this.get("id");
    assert(id != null, "Cannot save Video entity without an ID");
    if (id) {
      **assert**(
        id.kind == ValueKind.STRING,
        `Entities of type Video must have an ID of type String but the id '${id.displayData()}' is of type ${id.displayKind()}`
      );
      store.set("Video", id.toString(), this);
    }
  }

  static load(id: string): Video | null {
    return **changetype**<Video | null>(store.get("Video", id));
Type error: Cannot find name 'assert'.

  20 |   save(): void {
  21 |     let id = this.get("id");
> 22 |     assert(id != null, "Cannot save Video entity without an ID");
     |     ^
  23 |     if (id) {
  24 |       assert(
  25 |         id.kind == ValueKind.STRING,
Type error: Cannot find name 'changetype'.

  32 | 
  33 |   static load(id: string): Video | null {
> 34 |     return changetype<Video | null>(store.get("Video", id));
     |            ^
  35 |   }
  36 | 
  37 |   get id(): string {

This is my tsconfig.ts file

{
  "compilerOptions": {
    "target": "es5",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "typeRoots": [
      "../node_modules/@types"
    ],
    "types" : [
      "core-js","node"
    ],

   
    "allowJs": true,
    "skipLibCheck": true,
    "strict": false,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "incremental": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve"
  },
  "baseUrl": ".", 
  "paths": {
    "@components/*" : ["./components/*"],
    "@pages/*" : ["./pages/*"],
    "@styles/*" : ["./styles/*"],
    "@utils/*" : ["./utils/*"],
    "@public/*" : ["./public/*"],
    "@assets/*" : ["./assets/*"],
    "@types/*" : ["./types/*"],
    "@clients/*" : ["./clients/*"],
    "@constants/*" : ["./constants/*"],
    "@layouts/*" : ["./layouts/*"],
    "@queries/*" : ["./queries/*"],
  },
  "include": [
    "next-env.d.ts",
    "**/*.ts",
    "**/*.tsx",
    "components", 
   "./*", 
   "@components/*",
   "@pages/**/*",
   "@src/**/*",
   "next.config.js", 
   "public"
  ],
  "exclude": [
    "node_modules",
    "typings/browser.d.ts",
    "typings/browser",
    
  ]
  
}

Packages.json

{
  "name": "Decentralized-YouTube",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "@apollo/client": "^3.6.9",
    "@babel/core": "^7.0.0",
    "@livepeer/react": "^0.4.0",
    "@nomicfoundation/hardhat-chai-matchers": "^1.0.0",
    "@nomicfoundation/hardhat-network-helpers": "^1.0.0",
    "@nomiclabs/hardhat-ethers": "^2.0.0",
    "@nomiclabs/hardhat-etherscan": "^3.0.0",
    "@rainbow-me/rainbowkit": "^0.6.0",
    "@typechain/ethers-v5": "^10.1.0",
    "@typechain/hardhat": "^6.1.2",
    "@types/chai": "^4.2.0",
    "@types/mocha": "^9.1.0",
    "avvvatars-react": "^0.4.2",
    "axios": "^0.27.2",
    "chai": "^4.2.0",
    "dotenv": "^16.0.2",
    "ethers": "^5.7.1",
    "graphql": "^16.6.0",
    "hardhat-gas-reporter": "^1.0.8",
    "ipfs-http-client": "^58.0.0",
    "livepeer": "^0.4.0",
    "moment": "^2.29.4",
    "next": "12.3.0",
    "plyr-react": "^5.1.0",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-hot-toast": "^2.4.0",
    "react-icons": "^4.4.0",
    "solidity-coverage": "^0.8.1",
    "ts-node": ">=8.0.0",
    "typechain": "^8.1.0",
    "wagmi": "^0.6.6",
    "web3.storage": "^4.4.0",
    "typescript": "^4.5.5"
  },
  "devDependencies": {
    "@nomicfoundation/hardhat-toolbox": "^2.0.0",
    "@types/core-js": "^2.5.5",
    "@types/node": "^18.15.0",
    "@types/react": "18.0.20",
    "autoprefixer": "^10.4.11",
    "eslint": "8.23.1",
    "eslint-config-next": "12.3.0",
    "eslint-config-prettier": "^8.7.0",
    "eslint-plugin-import": "^2.26.0",
    "hardhat": "^2.11.2",
    "postcss": "^8.4.16",
    "tailwindcss": "^3.1.8",
    
  }
}

Tried upgrading, downgrading packages , declare var assert:any and var changetype:any but then it says on changetypes’s turn :

Type error: Untyped function calls may not accept type arguments.

first on ubuntu then on windows but in vain
tried different suggestions from stackoverflow of adding lines to eslintrc and tsconfig.json file

How to add a validation in a bootstrap form with FullCalendar?

I’m doing a shift system for a barber shop, using FullCalendar.
I added a custombutton (FullCalendar provides it), which opens a new window to complete a form with name, day and hour, but I need to add a validation for the day and the hour.
For example:
Haircut days only are available from Tuesday to Saturday, and on the hours of 10 AM until 7 PM, so I need a validation in the form for that.
So I added this to the FullCalendar code in Javascript:

customButtons: {
        custom1: {
          text: 'Ask haircut shift',
          click: function(){
            // Opens form in a new windows
            var popup = window.open('haircut-shift.html', 'Ask shift', 'width=500,height=500');
            popup.onbeforeunload = function(){
              calendar.refetchEvents();
            };
          }
        }
      }

As you can see, window.open refeers to another .html archive that contains the form (made with bootstrap).
Tried to add another function that checks day and hour but seems not to be working properly, because whenever I select Monday and 9 PM i.e., let’s me save it without any alert..
Any suggestion?

Tried to add another function to test the validation but doesn’t worked:

    eventClick: function(info) {
      if (info.event.start.getDay() < 2 || info.event.start.getDay() > 6) {
        alert('Haircut shift only available from tuesday to saturday');
        return;
      }
      if (info.event.start.getHours() < 10 || info.event.start.getHours() >= 19) {
        alert('Haircut shift only available from 10 AM until 7 PM)';
        return;
      }
      var popup = window.open('haircut-shift.html', 'Ask shift', 'width=500,height=500');
      popup.onbeforeunload = function(){
        calendar.refetchEvents();
      };
    },

how to deal with “CORS error” when writing firefox plugin?

I am trying to write a plugin for Firefox that keeps track of changes of several websites. To do this, I would need to maintain a list of websites and do “HTTP GET” to get their latest contents using following code:

function httpGet(theUrl)
{
    var xmlHttp = new XMLHttpRequest();
    xmlHttp.withCredentials = true;
    xmlHttp.open( "GET", theUrl, false ); // false for synchronous request
    xmlHttp.setRequestHeader('Access-Control-Allow-Origin', '*');
    xmlHttp.send( null );
    return xmlHttp.responseText;
}

However, I constantly have following error:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors/CORSMissingAllowOrigin. (Reason: CORS request did not succeed). Status code: (null)

Does anyone know how I should fix this issue? Any suggestion would be much appreciated, thanks!

Add Task in specified column

I work on simple Kanban Board, and I want to add new task when I click the button in each column, but when i click any button it adds task to only the first column, and i want it in each column if I clicked it’s button
Here’s my code ,Please review

 <div class="container">
    <div class="row">
      <h2>Not Started</h2>
      <ul class="tasks">
      </ul>
      <button class="btn" id="btn">+ Add(1)</button>
    </div>
    <div class="row">
      <h2>In Progress</h2>
      <ul class="tasks">
      </ul>
      <button class="btn" id="btn">+ Add(2)</button>
    </div>
    <div class="row">
      <h2>Completed</h2>
      <ul class="tasks">
      </ul>
      <button class="btn" id="btn">+ Add(3)</button>
    </div>
  </div>
const btns = document.querySelectorAll("button");
const tasks = document.querySelector(".tasks");
const rows = document.querySelectorAll(".row");

// Add task
function addContent() {
    const newElement = document.createElement("li");
    newElement.className = "input-container";
    const input = document.createElement("input");
    input.type = "text";

    const content = `<input type="text" class="field" id="input">
  
    <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"
    class="w-6 h-6 edit icon">
    <path stroke-linecap="round" stroke-linejoin="round"
    d="M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L6.832 19.82a4.5 4.5 0 01-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 011.13-1.897L16.863 4.487zm0 0L19.5 7.125" />
    </svg>
  
    <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"
    class="w-6 h-6 remove icon">
    <path stroke-linecap="round" stroke-linejoin="round"
    d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0" />
    </svg>
    `;

    newElement.innerHTML += content;
    tasks.appendChild(newElement);
}

// Event Listeners
btns.forEach((btn) => {
    btn.addEventListener("click", addContent.bind(this));
});

I can’t include the RobotJS module in my ElectronJS project

I am developing a desktop application for Windows using ElectronJS. I want to include the RobotJS module in my project, but I can’t seem to figure out how to do it. I successfully downloaded the module by running ‘npm install robotjs’ and called it in the main.js file. However, when I try to launch the application, I get the error shown in the image below. What could be causing this issue? I would be very grateful if you could help me solve my problem. If there is any additional information you need to learn in order to solve the issue, please let me know and I will send it quickly. Thank you in advance for your assistance!

npm version:

Error:

main.js file:

const { app, BrowserWindow, Tray, Menu, ipcMain } = require('electron');
const path = require('path');
var robot = require("robotjs");


let mainWindow = null;
let tray = null;

function createWindow() {
  mainWindow = new BrowserWindow({
    width: 1182,
    height: 503,
    show: true,
    webPreferences: {
      nodeIntegration: true,
      contextIsolation: false
    },
    autoHideMenuBar: true,
    resizable: false,
    fullscreenable: false
  });

  mainWindow.loadFile('index.html');

  mainWindow.on('close', (event) => {
    event.preventDefault();
    mainWindow.hide();
  });
}

function createTray() {
  tray = new Tray(path.join(__dirname, 'img/cf.ico'));

  const contextMenu = Menu.buildFromTemplate([
    {
      label: 'Exit',
      click: () => {
        app.exit();
      },
    },
  ]);

  tray.on('click', () => {
    mainWindow.show();
  });

  tray.setToolTip('Casefife Prodeck');
  tray.setContextMenu(contextMenu);
}

app.on('ready', () => {
  createTray();
  createWindow();
});

app.on('activate', () => {
  if (mainWindow === null) {
    createWindow();
  }
});

app.on('window-all-closed', () => {
  if (process.platform !== 'darwin') {
    app.quit();
  }
});

I can’t include the RobotJS module in my ElectronJS project

How to specify the migration folder path in node-pg-migrate?

I’m using the package node-pg-migrate to control my migrations, but i can’t specify the folder i want to create the migration file in CLI.

When i run node-pg-migrate create my first migration --migration-dir .srcinfradbconfigpgmigrations i got an error:

Error: ENOENT: no such file or directory, open 'C:UsersPTIDocumentsprojectsArchMastermigrations1678477686024_my-first-migration-.srcinfradbconfigpgmigrations.js'

It’s seens that “create” does’nt support specify the directory, is that rigth?

Kendo datasource to export to Excel does not read through JSON data

I am using Kendo to export data to an Excel spreadsheet. The data is returned to me from a C# MVC application. I then execute JSON.parse on the data and send the data to a javascript function. This is an image of what the data object looks like in the console.log:

enter image description here

There are 2 records being returned by the MVC application. The image above shows the data in the first record.

I have this code which should cycle through the data records and push data into the row object:

    var ds = new kendo.data.DataSource({
        data: PassedData
    });

    var rows = [{
        cells: [
            { value: "FileNo" }, { value: "CaseKey" }, { value: "RecordNumber" }, { value: "ActualRefund" }, { value: "AffidavitReceived" },
            { value: "AffidavitToClient1" }, { value: "AffidavitToClient2" }, { value: "ClientInvoiced" }, { value: "DNB" }, { value: "DSBL" },
            { value: "EstimatedRefund" }, { value: "FinalAV" }, { value: "GeneralTaxRate" }, { value: "GeneralTaxRateYear" }, { value: "GrossFee" },
            { value: "InvoicePaid" }, { value: "LastUpdate" }, { value: "NassauPARID" }, { value: "NegotiatingAttorney" }, { value: "NetFee" },
            { value: "Notes" }, { value: "OfferAccepted" }, { value: "OfferToClient" }, { value: "OriginalAV" }, { value: "Per" },
            { value: "Reduction" }, { value: "RefundDate" }, { value: "SchoolTaxRate" }, { value: "SchoolTaxRateYear" }, { value: "SettlementDate" },
            { value: "SettlementType" }, { value: "TaxYear" }, { value: "ToTreasurer" }, { value: "Unit" }, { value: "UpdatedBy" }
        ]
    }];
    ds.fetch(function () {

        for (var i = 0; i < ds.data.length; i++) {
            // Push single row for every record.
            rows.push({
                cells: [
                    { value: ds.data[i].Fileno }, { value: ds.data[i].CaseKey }, { value: ds.data[i].ID }, { value: ds.data[i].ActualRefund }, { value: ds.data[i].AffidavitReceived },
                    { value: ds.data[i].AffidavitToClient1 }, { value: ds.data[i].AffidavitToClient2 }, { value: ds.data[i].ClientInvoiced }, { value: ds.data[i].DNB }, { value: ds.data[i].DSBL },
                    { value: ds.data[i].EstimatedRefund }, { value: ds.data[i].FinalAV }, { value: ds.data[i].GeneralTaxRate }, { value: ds.data[i].GeneralTaxRateYear }, { value: ds.data[i].GrossFee },
                    { value: ds.data[i].InvoicePaid }, { value: ds.data[i].LastUpdate }, { value: ds.data[i].NassauPARID }, { value: ds.data[i].NegotiatingAttorney }, { value: ds.data[i].NetFee },
                    { value: ds.data[i].Notes }, { value: ds.data[i].OfferAccepted }, { value: ds.data[i].OfferToClient }, { value: ds.data[i].OriginalAV }, { value: ds.data[i].Per },
                    { value: ds.data[i].Reduction }, { value: ds.data[i].RefundDate }, { value: ds.data[i].SchoolTaxRate }, { value: ds.data[i].SchoolTaxRateYear }, { value: ds.data[i].SettlementDate },
                    { value: ds.data[i].SettlementType }, { value: ds.data[i].TaxYear }, { value: ds.data[i].ToTreasurer }, { value: ds.data[i].Unit }, { value: ds.data[i].UpdatedBy }
                ]
            })
        }
 });

As you can see from the bottom of the image, javascript is generating this error:

Uncaught TypeError: Cannot read properties of undefined (reading 'Fileno')

When I click on the error in the console.log, this is what I see:

enter image description here

As a test, I changed ds.data[i].Fileno to ds.data[i].CaseKey and then javascript reports the error on ds.data[i].CaseKey so it must be something with the way I am referencing the datasource records.

Any assistance is greatly appreciated.
Thank you.

Google Maps Icon size scaledSize multiple icon array

I have a google map that I have inherited with multiple map location icons. I would like to set the icon size with the scaledSize property as I have done before with other maps. But the location icons are ran through a for loop. How would I apply the scaledSize property to all items in the array to size all map location icons? Any help would be greatly appreciated.

// GOOGLE MAP
function initMap() {
  var map = new google.maps.Map(document.getElementById("map"), {
    zoom: 7,
    center: new google.maps.LatLng(53.41291, -7.94389),
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    mapTypeControl: false,
    scrollwheel: false,
    styles: [
 ],
  });
  var locations = [
    [
      "<h3>Crowne Plaza Dublin Airport</h3> <p>Park Northwood<br/>Santry<br/>Dublin 9<br/>Ireland<br/>D09 X9X2</p>",
      53.404402,
      -6.245599,
      "/wp-content/themes/tifcohotels-child/assets/img/map/crowneplaza-map-marker.svg",
    ],
    [
      "<h3>Holiday Inn Express Dublin Airport</h3> <p>Northwood Park<br/>NorthWood<br/>Dublin 9<br/>Ireland<br/>D09 RY17</p>",
      53.404275,
      -6.244526,
      "/wp-content/themes/tifcohotels-child/assets/img/map/holiday-express-map-marker.svg",
    ],
    [
      "<h3>Crowne Plaza Dublin - Blanchardstown</h3> <p>The Blanchardstown Centre<br/>Dublin 15<br/>Ireland<br/>D15 T1FD</p>",
      53.395652,
      -6.389966,
      "/wp-content/themes/tifcohotels-child/assets/img/map/crowneplaza-map-marker.svg",
    ],
];

  var infowindow = new google.maps.InfoWindow();
  var marker, i;
  var markers = new Array();
  for (i = 0; i < locations.length; i++) {
    marker = new google.maps.Marker({
      position: new google.maps.LatLng(locations[i][1], locations[i][2]),
      icon:
      locations[i][3], 
      // scaledSize: new google.maps.Size(45, 69)
      map: map,
    });
    markers.push(marker);
    google.maps.event.addListener(
      marker,
      "click",
      (function (marker, i) {
        return function () {
          infowindow.setContent(locations[i][0]);
          infowindow.open(map, marker);
        };
      })(marker, i)
    );
  }

  // Add a marker clusterer to manage the markers.
  var markerCluster = new MarkerClusterer(map, markers, {
    imagePath:
      "https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m",
  });
}

Setting the ID order in Handsontable

I have set up an HTML table using Handsontable. I want the ID to be sorted starting from row 2. How can I do it?

    window.hot = new Handsontable(container, {
    data: datas,
    rowHeaders: true,
    colHeaders: false,
    dropdownMenu: true,
    contextMenu: true,
    height: 'auto',
    // width: '100%',
    // stretchH: 'last',
    contextMenu: true,

    cells: function (row, col) {
        let cellProperties = {};
        if (row == 0) {
            // Highlight the first row
            cellProperties.className = 'spotlight'
        }
        return cellProperties;
    },

    licenseKey: 'non-commercial-and-evaluation'
});
}

enter image description here

Logout from previous sessions npm passport

I’m using passport for authentication purpose. I wanted to logout from previous sessions (be it on different browser or device) when user tries to login with new session.

I know I can user req.logout to log out but I’m not sure how to destroy all other sessions from db which my passport is creating while login.

Any suggestions?

The following is my passport config

const passport = require('passport'),
    LocalStrategy = require('passport-local').Strategy,
    User = require('../database/Schema').User,
    shortid = require('shortid');

passport.serializeUser( (user, cb) => {
    cb(null, user);
});

passport.deserializeUser( (obj, cb) => {
    cb(null, obj);
});

passport.use('localRegister', new LocalStrategy({
        usernameField: 'email',
        passwordField: 'password',
        passReqToCallback: true
    },
    (req, email, password, done) => {
        User.findOne({$or: [{email: email}, {username: req.body.username}]},  (err, user) => {
            if (err)
                return done(err);
            if (user) {
                if (user.email === email) {
                    req.flash('email', 'Email is already taken');
                }
                if (user.username === req.body.username) {
                    req.flash('username', 'Username is already taken');
                }

                return done(null, false);
            } else {
                let user = new User();
                user.email = email;
                user.password = user.generateHash(password);
                user.username = req.body.username;
                user.stream_key = shortid.generate();
                user.save( (err) => {
                    if (err)
                        throw err;
                    return done(null, user);
                });
            }
        });
    }));

passport.use('localLogin', new LocalStrategy({
        usernameField: 'email',
        passwordField: 'password',
        passReqToCallback: true
    },
    (req, email, password, done) => {

        User.findOne({'email': email}, (err, user) => {
            if (err)
                return done(err);

            if (!user)
                return done(null, false, req.flash('email', 'Email doesn't exist.'));

            if (!user.validPassword(password))
                return done(null, false, req.flash('password', 'Oops! Wrong password.'));

            return done(null, user);
        });
    }));


module.exports = passport;

The following is my user schema (I’m using mongodb)

let mongoose = require('mongoose'),
    bcrypt   = require('bcryptjs'),
    shortid = require('shortid'),
    Schema = mongoose.Schema;

let UserSchema = new Schema({
    username: String,
    email : String,
    password: String,
    stream_key : String,
});

UserSchema.methods.generateHash = (password) => {
    return bcrypt.hashSync(password, bcrypt.genSaltSync(8));
};

UserSchema.methods.validPassword = function(password){
    return bcrypt.compareSync(password, this.password);
};

UserSchema.methods.generateStreamKey = () => {
    return shortid.generate();
};

module.exports = UserSchema;

The following is my login route

const express = require('express'),
    router = express.Router(),
    passport = require('passport');

router.get('/',
    require('connect-ensure-login').ensureLoggedOut(),
    (req, res) => {
        req.logOut();
        res.render('login', {
            user : null,
            errors : {
                email : req.flash('email'),
                password : req.flash('password')
            }
        });
    });

router.post('/', passport.authenticate('localLogin', {
    successRedirect : '/',
    failureRedirect : '/login',
    failureFlash : true
}));

module.exports = router;

how to Read .txt file on new activity when i click textview

I want to Read .txt file on new activity (for example “secondactivity.tk”) when i click Textview, i succefully read text but just in same Activity,
here is my code

so please what should i add in the mainactivity and secondactivity

package com.example.coding

import android.content.Intent
import android.os.Bundle
import android.view.View
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import java.io.IOException

class Dusterlist : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_dacialist)
        var string = ""
        var myoutput = string
        val txtsh1 = findViewById<TextView>(R.id.txtsh1)
        val txt7 = findViewById<TextView>(R.id.textView7);
        txt7.setOnClickListener(View.OnClickListener {
            try {
                val inputStream = assets.open("marques/DACIA/Duster/Affichage de la temperature mouteur.txt")
                val size: Int = inputStream.available()
                val buffer = ByteArray(size)
                inputStream.read(buffer).toString()
                string = String(buffer)
                var txtdetail = String(buffer)
                txtsh1.text = txtdetail

            } catch (e: IOException) {
                e.printStackTrace()
                }


        } )}

    }