Skip to content

How to use Auth

Ayman Habeb edited this page Jul 11, 2016 · 20 revisions

Auth (Authentication)

Some plugins require the user to be authenticated before continuing on to a particular feature. Auth is used to login and to register on the BuildFire auth server. This article goes through the steps for using Auth.

Login


How to use Auth

Methods:

buildfire.auth.login([options], callback);

This method will check if the current user is logged in or not. If not, buildfire.js will open the login UI.

arguments

  • options: default: null .. not used.
  • callback: is a function that is called when the data is retrieved from the datastore. The callback function is called after login or registration is successful.

buildfire.auth.logout();

This method is seen when you logout from auth.

arguments

  • options: default: null .. not used.
  • callback: is a function that is called when the data is retrieved from the datastore. The callback function is called after login or registration is successful.

buildfire.auth.getCurrentUser(callback);

This method gives the current logged in user.

arguments

  • callback(err,user): is a function that is called with the current logged in user if exists.
    • err: if there was an error when attempting to retrieve the user
    • user: the user object containing public user properties

arguments

  • callback: the callback function contains the current logged in user.

buildfire.auth.onLogin(callback, [allowMultipleHandlers]);

This method allows you to pass a callback function that is called whenever the user is logged in.

arguments

  • callback: the callback function contains the current loggedin user.
  • allowMultipleHandlers: optional bool param that tells the method to override all other handlers. Default false

##buildfire.auth.onLogout(callback, [allowMultipleHandlers]); This method allows you to pass a callback function that is called whenever the user is logged out.

arguments

  • callback it’s a callback function contains the current loggedin user.
  • allowMultipleHandlers: optional bool param that tells the method to override all other handlers. Default false

##buildfire.auth. getUserProfile(options,callback); - (beta) This method will pull a public profile for a user if you have the userId.

arguments

  • 'options: {userId: XXX }'
  • callback (err, profile) it’s a callback function contains the profile user.

##buildfire.auth.openProfile(userId); This method will redirect the app to view user profile page.

arguments

  • userId: 'XXX'
Clone this wiki locally