JSON.stringify(data); to Array

Hello, i have an issue in the process of making an authentication system for LoginForm
First step, i have JSON which is like that →

[{“Mobile1”:“6946504924”,“Code”:“0007130”,“Name”:“ΚΡΕΜΥΔΑΣ ΤΑΣΣΟΣ”},{“Mobile1”:“6977263273”,“Code”:“0007134”,“Name”:“ΚΥΡΙΑΚΟΠΟΥΛΟΣ ΧΑΡΗΣ”},{“Mobile1”:“6982773110”,“Code”:“0007145”,“Name”:“Καγιαμπάκη Κατερίνα”,“EMail”:“katerinakagiampaki@triadelta.gr”},{“Mobile1”:“6977460370”,“Code”:“0007170”,“Name”:“ΜΠΛΙΚΑΣ”},{“Mobile1”:“6979836438”,“Code”:“0007188”,“Name”:“ΠΑΓΩΝΗΣ ΝΙΚΟΛΑΟΣ”},{“Mobile1”:“6940993942”,“Code”:“0007190”,“Name”:“ΣΠΥΡΟΣ ΠΩΛΗΤΗΣ”},

Second Step i set Mobile1 and Code values to variables this.Mobile and this.Code in order to manage them later, but because i have a lot of objects with mobile1,Code etc i made a FOR-LOOP in order to make a list or an array in which i store the data and then check the stored data with the input data from the End User and make the authentication.If Mobile1 and Code match then a message will pop-out and it will say that “Valid Credentials " and if not " ERROR Code or Mobile Please Try Again”.
I am sending you also my coding page.

 scrid() {
    console.log("Entered into Scrid");
    this.url = webApihost + "api/rpc/SimpleScrollerRootTable/" + scrid;
    this.paramsScroller.data.Code = "0013168";

    return this.getScrid(this.url, this.paramsScroller)
      .subscribe((Scrid:any) => {
         console.log(JSON.stringify(Scrid));
         for(var i=0; i<Scrid.length; i++){
           this.Mobile=Scrid[i].Mobile1;
           this.Code=Scrid[i].Code;
           console.log("Mobile phone : "+this.Mobile+"  Code User: "+this.Code);

         }

        // console.log("Kinito "+this.Mobile+"& Kodikos "+this.Code);

      });

  }

My problem is How do i store them in an array and how do i check them and compare them with the Input data that i get from the login screen?

You have a much bigger problem, which is that this scheme doesn’t authenticate anything at all. Anybody with a copy of that JSON, whether it is baked into your app binary or retrieved from an open backend can easily spoof any user in the system.

Don’t try to reinvent the wheel here. Use JWT and a proper password hashing function like bcrypt, scrypt, or PBKDF2.

1 Like