External Page Authentication

From KickApps Documentation

Jump to: navigation, search

Description

The following code snippet will check to see if the end user's browser is currently logged in to a given KickApps site. If so, it will return a JSON, "data", which will include limited information about the logged in user.

Code

var url = "http://affiliate.kickapps.com/service/isUserLoggedIn.kickAction?callback=?" 
function checkLogin(data) {
   if(data.isLoggedIn == "true") {
       // Do logged in stuff
      $('#userName').html(data.username);
      $('#userName').attr('href',  'http://affiliate.kickapps.com/service/displayKickPlace.kickAction?u=' + data.userid + '&as=#####');
   } else {
       // Do logged out stuff
   }
 } 

$.ajax({ dataType: 'jsonp', data: {as: ######}, jsonp: 'checkLogin', url: url, success: checkLogin }); 
</script>


Usage

This script is fairly simple to use. On your external pages, wherever you'd like the content to be displayed, for an authenticated user, place this script inside that element in your markup. Be sure to replace the ###### value for the AS in the ajax call with your communities ASID.