mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-29 17:32:17 -07:00
Merge b2f63255f0 into 18b4ffefa8
This commit is contained in:
commit
13fbe977d4
11 changed files with 238 additions and 3 deletions
|
|
@ -179,6 +179,15 @@ public:
|
|||
{
|
||||
return false;
|
||||
}
|
||||
/** @brief Record a failed login attempt from the given address; returns true if the address is now locked out. */
|
||||
virtual bool recordFailedLogin(const QString & /*ipAddress*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
/** @brief Clear any failed-login lockout for the given address, e.g. after a successful login. */
|
||||
virtual void clearFailedLogins(const QString & /*ipAddress*/)
|
||||
{
|
||||
}
|
||||
|
||||
Server_DatabaseInterface *getDatabaseInterface() const;
|
||||
int getNextLocalGameId()
|
||||
|
|
|
|||
|
|
@ -549,10 +549,14 @@ Response::ResponseCode Server_ProtocolHandler::cmdLogin(const Command_Login &cmd
|
|||
return Response::RespUserIsBanned;
|
||||
}
|
||||
case NotLoggedIn:
|
||||
if (server->recordFailedLogin(getAddress())) {
|
||||
return Response::RespTooManyRequests;
|
||||
}
|
||||
return Response::RespWrongPassword;
|
||||
case WouldOverwriteOldSession:
|
||||
return Response::RespWouldOverwriteOldSession;
|
||||
case UsernameInvalid: {
|
||||
server->recordFailedLogin(getAddress());
|
||||
auto *re = new Response_Login;
|
||||
re->set_denied_reason_str(reasonStr.toStdString());
|
||||
rc.setResponseExtension(re);
|
||||
|
|
@ -563,8 +567,10 @@ Response::ResponseCode Server_ProtocolHandler::cmdLogin(const Command_Login &cmd
|
|||
case ClientIdRequired:
|
||||
return Response::RespClientIdRequired;
|
||||
case UserIsInactive:
|
||||
server->recordFailedLogin(getAddress());
|
||||
return Response::RespAccountNotActivated;
|
||||
default:
|
||||
server->clearFailedLogins(getAddress());
|
||||
authState = res;
|
||||
usingRealPassword = needsHash;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue