Add role checking to login. Add logging. Improve error handling