File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
app/src/main/java/com/ismartcoding/plain/web Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ import io.ktor.server.plugins.origin
76
76
import io.ktor.server.plugins.partialcontent.PartialContent
77
77
import io.ktor.server.request.header
78
78
import io.ktor.server.request.receiveMultipart
79
+ import io.ktor.server.request.receive
79
80
import io.ktor.server.request.receiveText
80
81
import io.ktor.server.response.header
81
82
import io.ktor.server.response.respond
@@ -666,6 +667,20 @@ object HttpModule {
666
667
return @post
667
668
}
668
669
HttpServerManager .clientIpCache[clientId] = call.request.origin.remoteAddress
670
+ // If request body is not empty, try to decrypt with the token corresponding to c-id.
671
+ // If decrypt succeeds, return 200; otherwise continue with the original handling.
672
+ val bodyBytes = runCatching { call.receive<ByteArray >() }.getOrNull()
673
+ if (bodyBytes != null && bodyBytes.isNotEmpty()) {
674
+ val token = HttpServerManager .tokenCache[clientId]
675
+ if (token != null ) {
676
+ val decryptedBytes = CryptoHelper .chaCha20Decrypt(token, bodyBytes)
677
+ if (decryptedBytes != null ) {
678
+ call.respond(HttpStatusCode .OK )
679
+ return @post
680
+ }
681
+ }
682
+ }
683
+
669
684
if (PasswordTypePreference .getValueAsync(MainApp .instance) == PasswordType .NONE ) {
670
685
call.respondText(HttpServerManager .resetPasswordAsync())
671
686
} else {
You can’t perform that action at this time.
0 commit comments