Fix lookup for username generation when ACCOUNTS_NO_USERNAME is True, closes #664.