1

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 ?

Vince
  • 691
  • 1
  • 8
  • 18

1 Answers1

3

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.

Ygalbel
  • 5,214
  • 1
  • 24
  • 32
  • Thank you @Ygalbel for this. I searched Backand Docs for this but couldn't find it prior to posting the thread. Are you able to direct me to documentation, if any ? – Vince Mar 10 '16 at 21:20
  • 1
    That's can be found [here](http://docs.backand.com/en/latest/apidocs/security/#sso-single-sign-on) and in sdk part with more details [here](http://docs.backand.com/en/latest/getting_started/sdk/#usage) – Ygalbel Mar 13 '16 at 15:50
  • The second link don't work, just search "getUserDetails" in search tab in help pages, and you will find it. – Ygalbel Mar 13 '16 at 15:54