Edit RegisterUser and some code cleaning

Added check for username and password
If invalid username or password throws status code 417