shell: Fix bad response when login with empty user name

Fix backend to return authentication failed if user is NULL.
Fix frontend to avoid empty user name.
Some refactoring.

Fixes #940
ws: Update test cases for previous commit

Closes #959