Search code examples
ionic-frameworkionic2ionic-cloud

How to check authenticated status server side with ionic cloud Auth


I'm evaluating whether to use Ionic's cloud Auth service and it seems like it's relatively easy to implement client-side, where you can check this.auth.isAuthenticated. You can also set the user info from the client side as well.

However, if I want to do check their identity server-side, such as check that a user is authenticated when they call my custom api to post a comment - how can I get some sort of token (preferably a JWT token) that I can use to validate their identity server-side? Assuming we are using email/password authentication.

Also - using their send notification on a user's birthday example, how can I query the user data in ionic cloud's database to say find all users who have a birthday today. Can I export out the user data in any way if I want to migrate away in the future?


Solution

  • You should implement a JWT authentication service server side. In other words when the user is authenticated, the app can send a JWT token to the server which should be evaluated to trust the remote user. For more info reads: https://docs.ionic.io/services/auth/custom-auth.html A php example here: https://github.com/driftyco/custom-auth-examples/tree/master/php

    Regards from Italy