Ionic sqlite fetch data not return


#1

let q2 = “SELECT * FROM users WHERE email =’”+this.user.username+"’ and password =’"+md5(this.user.password,‘hex’)+"’";

           this.getFetch(q2);
             let alert = this.alertCtrl.create({
                title: "Giriş Başarılı",
                subTitle: JSON.stringify(this.userinfo),
                buttons: ["OK"]
                });
                alert.present();

getFetch(sql)
{
this.getinfo(sql).then(res => {
this.contacts = res;
});
}

getinfo(sql){

return this.sqlite.create({
  name: 'data.db',
  location: 'default'
}).then((db: SQLiteObject) => {
  return db.executeSql(sql, []).then(res => {
    let contacts = [];
    for (var i = 0; i < res.rows.length; i++) {
      contacts.push(res.rows.item(i));
    }
    return Promise.resolve(contacts);
  }).catch(e => {
    return Promise.resolve(e);
  });
}).catch(e => {
  return Promise.resolve(e);
});

}

I want to get member name and id but it is returning empty help me please


#2

Please edit your post and use the </> button above the post input field to format your code or error message or wrap it in ``` (“code fences”) manually. This will make sure your text is readable and if it recognizes the programming language it also automatically adds code syntax highlighting. Thanks.


#3

This is a really unusual setup, having authentication information on the device. Why are you doing this instead of on a server that you can secure?


#4

I use it for Offline mode.


#5

And you’re OK with every user of this device knowing the passwords of every other user? That would scare the hell out of me.


#6

What to do for offline mode


#7

Impossible to answer without knowing what the app does.


#8

Simple notification system. I want to login both online and offline


#9

This is like getting blood out of a turnip. Can you elaborate somewhat?


#10

A system where users can sign in and create a notification for themselves from here.


#11

Typically, apps assume that a device has only one user. Your situation is apparently different, in that a single device has multiple users (in fact, so many of them that you feel the need to resort to manually interacting with SQLite in order to be able to do all sorts of complex SQL queries about them). Why is this? How many potential users are there for each device? What is their relationship to one another?

What sort of activity needs to be done offline? What is the process for transferring offline activity once the app goes to online mode?


#12

I get the data from the server when I go online and transfer the sqlite. Actually my goal is to offer both online and offline usage


#13

If I’m understanding you correctly, you are publicly serving user authentication information for every registered user of your app. When blackhat crackers gain unauthorized access to servers, this is the sort of thing that they publish, making newspaper headlines and getting heads of security fired. You are giving it away to anybody for free.

I would radically rethink this design so that authentication is only required for online mode and transfer. The device can hold a JWT, or you can delay requiring the password until the device is online. The synchronization code is the only bit that needs to know who the authenticated user is; I would make the offline activities be generic, not needing to know this information. You could store just a username if needed for display purposes.

Oh, and don’t use MD5, even on the server. I would recommend bcrypt for hashing passwords. It is much more secure, and even immune to rainbow tables.