Query Iguana User Role/Email

Introduction

The iguana.user module can be helpful when you have a web service you need to authenticate. The module could be fleshed out more, currently it shows how one can query if a user belongs to a given group, and find their email address.

If you have any questions please contact us at support@interfaceware.com.

Using the Code [top]

  • Import the Query Iguana User Role/Email channel from the Builtin: Iguana Webservices repository
  • Experiment with the code to find out how it works
  • Then add the module(s) to your Translator project
  • Copy the require statement from the channel and add it at the top of your script
    Note: This module uses require to return a table
  • Use user.open() to load the Iguana user database
  • Use info:userInGroup{} to check for group membership
  • Use info:user{} to return user information
    Note: Currently only returns email but more data can be added
  • Adapt the code to your own requirements
  • Interactive scripting help is included for this module

This is the github code for the main module:

How it works [top]

The iguana.user module checks group membership against the Iguana user database, and also returns the email address for a user.

The process is quite straightforward:

  1. Use user.open() to load the Iguana user database
  2. Use Info:userInGroup{} to check for group membership
  3. Use Info:user{} to return information about a user (currently only returns email address)

It is quite simple to modify the method:user() function in the user.lua module to return other information.

The code uses metadata which may seem daunting (but you don’t need to understand how that works). In fact the code is actually really easy to modify, you just need to change the return statement.

Line 100 getmetable(self).info returns this table containing the Iguana user database information:

Line 111 simply returns a specified field from that table:

All you need to do is change it to refer to a different field in the table. For example info.Users would return a table containing the user names of all the users on the system.

If you have any questions please contact us at support@interfaceware.com.

More information [top]

Leave A Comment?