From 3c59cf14745b9de2b175de901a0a27a3d6d03ae9 Mon Sep 17 00:00:00 2001 From: alterwain Date: Sun, 16 Mar 2025 17:40:14 +0300 Subject: [PATCH] Sign up added (for xcraft) x2 --- src/main/java/com/alterdekim/xcraft/auth/SaltNic.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/alterdekim/xcraft/auth/SaltNic.java b/src/main/java/com/alterdekim/xcraft/auth/SaltNic.java index 7fb417b..1da6f16 100644 --- a/src/main/java/com/alterdekim/xcraft/auth/SaltNic.java +++ b/src/main/java/com/alterdekim/xcraft/auth/SaltNic.java @@ -63,6 +63,7 @@ public class SaltNic extends NanoHTTPD { private Response handleHasJoinedRequest(IHTTPSession session) { String uuid = UserId.generateUserId(session.getParameters().get("username").get(0)); if( this.sessions.containsKey(uuid) && this.sessions.get(uuid) ) { + this.sessions.remove(uuid); return newFixedLengthResponse(Response.Status.OK, "application/json", "{\n" + " \"id\" : \""+uuid+"\",\n" + " \"name\" : \""+session.getParameters().get("username").get(0)+"\",\n" + @@ -101,7 +102,9 @@ public class SaltNic extends NanoHTTPD { UserStorage.saveUser(uuid, PasswordHasher.hashPassword(password)); - return newFixedLengthResponse(Response.Status.OK, "text/plain", "User registered successfully"); + JSONObject response = new JSONObject(); + response.put("uuid", uuid); + return newFixedLengthResponse(Response.Status.OK, "text/plain", response.toJSONString()); } catch (Exception e) { logger.warning("Error while processing sign up request from client: " + e.getMessage()); return newFixedLengthResponse(Response.Status.INTERNAL_ERROR, "text/plain", "Server error: " + e.getMessage());