Create and manage temporary anonymous user sessions

Key Features Server-Side Usage: // Get the AnonymousSession API var AnonymousSession = js.getObject("/OpenForum/AddOn/AnonymousSession","AnonymousSession.sjs"); // Generate a session var session = AnonymousSession.generateSession("GuestUser", "password123"); // Returns: {sessionId: "abc12345", name: "GuestUser", password: "..."} // Generate session without password var session = AnonymousSession.generateSession("GuestUser", null); Use Cases //OpenForum/AddOn/AnonymousSession/get.sjs/** * Autogenerated by Service Builder v2.0.3. Do not edit. * Version: 0.0.2 * Built Fri Feb 19 2021 14:37:24 GMT-0000 (GMT) * Built to pageName:/OpenForum/AddOn/AnonymousSession fileName:get.sjs **/ /* * Author: * Description: */ var action = transaction.getParameter("action"); if(action===null) { transaction.setResult(transaction.SHOW_PAGE); return; } try{ action = ""+action; result = {result: "error", message: "Action "+action+" not recognised."}; var AnonymousSession = js.getObject("/OpenForum/AddOn/AnonymousSession","AnonymousSession.sjs"); if(action==="generateSession") { var name = transaction.getParameter("name"); if(name===null) { delete name; } else { name = "" + name; } var password = transaction.getParameter("password"); if(password===null) { delete password; } else { password = "" + password; } var fob = transaction.getParameter("fob"); if(fob===null) { delete fob; } else { fob = "" + fob; } var fobPassword = transaction.getParameter("fobPassword"); if(fobPassword===null) { delete fobPassword; } else { fobPassword = "" + fobPassword; } var returned = AnonymousSession.generateSession( name,password, fob, fobPassword ); if(returned) result = {result: "ok", message: "Performed action "+action, data: returned}; } if(action==="validateSession") { var key = transaction.getParameter("key"); if(key===null) { delete key; } else { key = "" + key; } var password = transaction.getParameter("password"); if(password===null) { delete password; } else { password = "" + password; } var returned = AnonymousSession.validateSession( key, password ); if(returned) result = {result: "ok", message: "Performed action "+action, data: returned}; } if(action==="getFobSessions") { var fob = transaction.getParameter("fob"); if(fob===null) { delete fob; } else { fob = "" + fob; } var fobPassword = transaction.getParameter("fobPassword"); if(fobPassword===null) { delete fobPassword; } else { fobPassword = "" + fobPassword; } var returned = AnonymousSession.getFobSessions( fob, fobPassword ); if(returned) result = {result: "ok", message: "Performed action "+action, data: returned}; } } catch(e) { transaction.sendJSON( JSON.stringify({result: "error",message: "Error:"+e+" on line "+e.lineNumber+" of "+e.sourceName})); return; } transaction.sendJSON( JSON.stringify(result) );