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.