Forum Discussion

1 Reply

  • Using node.js
    router.get('/', function(req, res) {
      // First, verify that a userID has been supplied
      var GATsecret = '', GATqrurl = '';
        var GATuserid = req.query.userid;
        var GATlogin = req.query.loginurl;
      if ( GATuserid ) {
        // Fetch the googleAppsKey records array and check for matching userid
          var bipCmdList = '/sys/failover';
          bip.list(bipCmdList, function(err, cres) {
              console.log(cres);
    
              var bipCmdList = '/ltm/dataGroup/internal/~Common~google_auth_keys?$select=records';
              bip.list(bipCmdList, function (err, bres) {
                  if (err) throw err;
                  if (!bres.records) {
                      holdList = {records: []};
                  }
                  else {
                      holdList = bres;
    
                  }
                  for (var i in holdList.records) {
                      if (holdList.records[i].name == GATuserid) {
                          GATsecret = holdList.records[i].data;
                      }
                  }
                  if (GATsecret.length != secretLength) {
                      GATsecret = random32(secretLength);
                      var newEntry = {"name": GATuserid, "data": GATsecret};
                      holdList.records.push(newEntry);
                      var bipCmdAdd = '/ltm/dataGroup/internal/~Common~google_auth_keys';
                      bip.modify(bipCmdAdd, holdList, function (err, ares) {
                          if (err) {
                              console.log(err);
                              throw err;
                          }
                      });
                  }
                  // Build the QRcode link
                  GATqrurl = getQRcode(GATuserid, GATdomain, GATsecret);
                  // Set the variables to be passed to Jade for rendering
                  res.render('index', {
                      title: 'ZeOmega Auth Secret',
                      showuserid: GATuserid,
                      showsecret: GATsecret,
                      showqr: GATqrurl,
                      nexturl: GATlogin
                  });
              });
          });
      }
    

    ==================================================================