Refactor password check and add cache clearance.

This commit is contained in:
2025-03-04 21:05:01 +01:00
parent f38b85f9cb
commit 9bc1f8b328
3 changed files with 3 additions and 1 deletions
@@ -335,7 +335,7 @@ public class SteamwarUser {
public boolean verifyPassword(String password) { public boolean verifyPassword(String password) {
try { try {
if (this.password == null) { if (!hasPassword()) {
return false; return false;
} }
@@ -48,6 +48,7 @@ fun main() {
while (true) { while (true) {
Thread.sleep(1000 * 10) Thread.sleep(1000 * 10)
ResponseUser.clearCache() ResponseUser.clearCache()
SteamwarUser.clear()
} }
}.start() }.start()
embeddedServer(Netty, port = 1337, host = "127.0.0.1", module = Application::module) embeddedServer(Netty, port = 1337, host = "127.0.0.1", module = Application::module)
@@ -61,6 +61,7 @@ fun Route.configureAuth() {
post { post {
val request = call.receive<UsernamePassword>() val request = call.receive<UsernamePassword>()
SteamwarUser.clear()
val user = SteamwarUser.get(request.name) val user = SteamwarUser.get(request.name)
val valid = user?.verifyPassword(request.password) ?: false val valid = user?.verifyPassword(request.password) ?: false