AuthMgr: base64 encode sha passwords. Database: fix syntax and foreign
keys