forked from SteamWar/SteamWar
Refactor password check and add cache clearance.
This commit is contained in:
@@ -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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user