Update username regex to support the same as webapp.

Rename password util to credentials and add a username check helper.
Move the username regexp to the credentials module.

Closes #5695.
Merge remote-tracking branch 'refs/remotes/ivan/feature/fix-username-regex-support' into develop