Authentication using for or filter ionic 3

I have a object “Trucks” and I trying to do a simple validation and nothing

I would like to do the following

    if(password == ‘…’ && placa == ‘…’)
      alert(login ok)
    else if (password != ‘…’)
      alert(‘error, password is wrong’)
    else if (placa!= ‘…’)
      alert(‘error, placais wrong’)

Im my login.ts I have the following code I don’t know if it’s right fist I get all trucks in list ok

getTrucks() {
            result => this.trucks = result

and the second on bellow I filter the trucks

  filterTruck() {
    return this.trucks.filter((item) => {
      if(item.placa == this.truck.placa && item.password == this.truck.password) {
          // this.navCtrl.setRoot('TabsPage');
          // this.auth.authentication(true);
          // this.auth.truckLogedd(user);
          // return true;
      } else if(item.placa != this.truck.placa) {

          return false;
      return false;

I’ve trying to use for but I did not make it

  filterTruck(users) {
    for(let user of users) {
      if(user.password != this.truck.password || user.placa != this.truck.placa) {
        this.showAlert('Ops!', 'Senha ou placa errada!')
      } else {

It would be almost right… but, no please…

You just can’t treat this client side, this is a security issue. Just send the inputed password and place to the backend, look at what correspond, and send appropriate response that you’ll treat in the answer.


Sorry, its not Validation but Authentication I already change the title my post, I want to authenticate

As @izio38 said, you can’t authenticate within the Ionic app. That must be done on the server.