mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-02-01 00:20:07 +00:00
WIP: basic server, no features
This commit is contained in:
@@ -124,6 +124,11 @@ public:
|
||||
void InsertUgcBuild(const std::string& modules, const LWOOBJID bigId, const std::optional<LWOOBJID> characterId) override;
|
||||
void DeleteUgcBuild(const LWOOBJID bigId) override;
|
||||
uint32_t GetAccountCount() override;
|
||||
void RecordFailedAttempt(const uint32_t accountId) override;
|
||||
void ClearFailedAttempts(const uint32_t accountId) override;
|
||||
void SetLockout(const uint32_t accountId, const int64_t lockoutUntil) override;
|
||||
bool IsLockedOut(const uint32_t accountId) override;
|
||||
uint8_t GetFailedAttempts(const uint32_t accountId) override;
|
||||
bool IsNameInUse(const std::string_view name) override;
|
||||
std::optional<IPropertyContents::Model> GetModel(const LWOOBJID modelID) override;
|
||||
std::optional<IUgc::Model> GetUgcModel(const LWOOBJID ugcId) override;
|
||||
|
||||
@@ -48,3 +48,39 @@ uint32_t SQLiteDatabase::GetAccountCount() {
|
||||
|
||||
return res.getIntField("count");
|
||||
}
|
||||
void SQLiteDatabase::RecordFailedAttempt(const uint32_t accountId) {
|
||||
ExecuteUpdate("UPDATE accounts SET failed_attempts = failed_attempts + 1 WHERE id = ?;", accountId);
|
||||
}
|
||||
|
||||
void SQLiteDatabase::ClearFailedAttempts(const uint32_t accountId) {
|
||||
ExecuteUpdate("UPDATE accounts SET failed_attempts = 0, lockout_time = NULL, last_login = CURRENT_TIMESTAMP WHERE id = ?;", accountId);
|
||||
}
|
||||
|
||||
void SQLiteDatabase::SetLockout(const uint32_t accountId, const int64_t lockoutUntil) {
|
||||
ExecuteUpdate("UPDATE accounts SET lockout_time = datetime(?, 'unixepoch') WHERE id = ?;", lockoutUntil, accountId);
|
||||
}
|
||||
|
||||
bool SQLiteDatabase::IsLockedOut(const uint32_t accountId) {
|
||||
auto [_, result] = ExecuteSelect("SELECT lockout_time FROM accounts WHERE id = ?;", accountId);
|
||||
if (result.eof()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const char* lockoutTime = result.getStringField("lockout_time");
|
||||
if (lockoutTime == nullptr || strlen(lockoutTime) == 0 || strcmp(lockoutTime, "0") == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If lockout_time is set and in the future, account is locked
|
||||
// For now, simplified check - if lockout_time exists, it's locked
|
||||
return true;
|
||||
}
|
||||
|
||||
uint8_t SQLiteDatabase::GetFailedAttempts(const uint32_t accountId) {
|
||||
auto [_, result] = ExecuteSelect("SELECT failed_attempts FROM accounts WHERE id = ?;", accountId);
|
||||
if (result.eof()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return result.getIntField("failed_attempts");
|
||||
}
|
||||
Reference in New Issue
Block a user