Allow period and numbers in firstname/lastname regex check (#144)

* Remove unnecessary whitespace check in regex
* Allow dot characters in names (except at the beginning of a name)
* Allow numbers in names
This commit is contained in:
darkredtitan 2020-11-08 22:34:02 +02:00 committed by GitHub
parent d505b09e98
commit 5293573116
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -438,8 +438,9 @@ bool CNLoginServer::isPasswordCorrect(std::string actualPassword, std::string tr
}
bool CNLoginServer::isCharacterNameGood(std::string Firstname, std::string Lastname) {
std::regex firstnamecheck("[a-zA-Z0-9]+(?: [a-zA-Z0-9]+)*$");
std::regex lastnamecheck("[a-zA-Z0-9]+(?: [a-zA-Z0-9]+)*$");
//Allow alphanumeric and dot characters in names(disallows dot and space characters at the beginning of a name)
std::regex firstnamecheck(R"(((?! )(?!\.)[a-zA-Z0-9]*\.{0,1}(?!\.+ +)[a-zA-Z0-9]* {0,1}(?! +))*$)");
std::regex lastnamecheck(R"(((?! )(?!\.)[a-zA-Z0-9]*\.{0,1}(?!\.+ +)[a-zA-Z0-9]* {0,1}(?! +))*$)");
return (std::regex_match(Firstname, firstnamecheck) && std::regex_match(Lastname, lastnamecheck));
}
#pragma endregion helperMethods