More work on login dialog and querying database