Ionic Auth GET user id

Hi,

I want to get my user id , but i can´t . How is it possible to get i?

Thanks

The Ionic Auth documentation doesn’t mention an ID at all: https://docs.ionic.io/services/auth/ Only for custom auth where it refers to the user_id of the custom auth service being implemented: https://docs.ionic.io/services/auth/custom-auth.html

May I ask why you need it and what you are trying to achieve?

@Sujan12 i am doing an app for iot control. I want to filter user devices and i thought that user id is the best option to do that.

I have found the solution:

this.db.collection('devices').findAll({creator: user.id}).fetch().subscribe( (devices) => {
  console.dir(devices);
  this.devices = devices;
}, (error) => {
  console.error(error);
});

you can call user.id and get the id.

Thanks

1 Like

Would mind let me know where do you put your code at? controller?

Ionic Auth is closing soon. Instead of getting it to work, you’d be better off finding a different auth provider.

1 Like