Added a check for user privileges before processing db queries Fixes #42