SmartPORTAL: User login API features

SmartPORTAL: User login API features

SmartPORTAL allows users to log in to your website using their Raiser's Edge NXT record. This means they can use the various SmartPORTAL forms such as login, profile updates, add action and the callhandler function.

On top of this it also provides a JavaScript based API through which you can use the Raiser's Edge NXT record data for your own purposes - restricting content by memberships, showing record fields to the user (email, name, addressee etc.). 

Example code

To accomplish this you need to add to your page an event listener to your page. There is an example below that uses this event listener to indicate if the user is logged in or not:
  1. <h2>SmartPORTAL Status:</h2><div id="status">Loading status...</div> <script>window.console = window.console || {
  2. log: function () {}
  3. };
  4. document.addEventListener("smartprofile_ready", function (data) {
  5. console.log(data);
  6.         console.log("Initialised SmartPORTAL LOGIN/OUT CODE RUSI");
  7. if (data.detail.loggedin) {
  8.                 $('#status').html('Logged in as ' + data.detail.constituent.name);
  9.         } else {
  10.                 $('#status').html('Not logged in');
  11.         }
  12. });</script>
In order for this event to fire you must have another SmartPORTAL snippet on the page OR use the snippet from the 'Addons' > 'Login check (and API support)' tab in the editor:

The Event

The event 'smartprofile_ready' is called with data about user. A sample data object is shown below. You can example this in Chrome by adding the above 'Login check...' snippet to a page and logging in as a user. Then open the console (F12 and go to the Console tab) and the 'CustomEvent' object displayed there will have the below object which you can review: