Search code examples
ionic-frameworkbackand

How to retrieve the currently logged in user with Backand


I am using the Backand BaaS for my Ionic app. I am trying to retrieve the currently logged in user.

At the moment I am setting a $rootScope variable upon the login event with the signed in user.

Is there an easier way to do this process without having to programatically set my own 'loggedInUser' variable ?


Solution

  • After you logged in, you can get user details with two methods.

     Backand.getUsername()
     Backand.getUserDetails()
    

    You have to add 'Backand' service to your controller.

    app.controller('ExampleCtrl', function(Backand){
         console.log(Backand.getUsername());
    }
    

    If user is not logged in, methods will return null.