login and register functionality with comments and error handling