Added some username checks, now usernames get stripped,
and only-spaces names are invaliAdded some username checks, now usernames get stripped, and only-spaces names are invalidd
This commit is contained in:
parent
cd5a5162b7
commit
35500b6027
1 changed files with 5 additions and 3 deletions
|
@ -190,9 +190,11 @@ void server::run()
|
|||
}
|
||||
|
||||
//check the username is valid (all alpha-numeric or space)
|
||||
const std::string& username = (*login)["username"];
|
||||
if(std::count_if(username.begin(),username.end(),isalnum) + std::count(username.begin(),username.end(),' ')
|
||||
!= username.size() || username.empty()) {
|
||||
std::string username = (*login)["username"];
|
||||
config::strip(username);
|
||||
const int alnum = std::count_if(username.begin(),username.end(),isalnum);
|
||||
const int spaces = std::count(username.begin(),username.end(),' ');
|
||||
if((alnum + spaces != username.size()) || spaces == username.size() || username.empty()) {
|
||||
network::send_data(construct_error(
|
||||
"This username is not valid"),sock);
|
||||
continue;
|
||||
|
|
Loading…
Add table
Reference in a new issue