Reimplement 'username check'

This reverts commit 55d3ce0984625edc05f0e6b801c583e207e819ab, thereby
reimplementing the username check so that I can send this pull request
atomically.