working on user data update
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
/* © SRSoftware 2025 */
|
||||
package de.srsoftware.umbrella.user;
|
||||
|
||||
public class Paths {
|
||||
|
||||
@@ -3,7 +3,6 @@ package de.srsoftware.umbrella.user;
|
||||
|
||||
import static de.srsoftware.tools.Optionals.nullable;
|
||||
import static de.srsoftware.umbrella.core.Constants.PASSWORD;
|
||||
import static de.srsoftware.umbrella.core.Constants.REDIRECT;
|
||||
import static de.srsoftware.umbrella.core.Paths.LOGOUT;
|
||||
import static de.srsoftware.umbrella.core.ResponseCode.*;
|
||||
import static de.srsoftware.umbrella.user.Constants.*;
|
||||
@@ -21,12 +20,10 @@ import de.srsoftware.umbrella.user.model.Password;
|
||||
import de.srsoftware.umbrella.user.model.Session;
|
||||
import de.srsoftware.umbrella.user.model.Token;
|
||||
import de.srsoftware.umbrella.user.model.UmbrellaUser;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class UserModule extends PathHandler {
|
||||
@@ -56,15 +53,11 @@ public class UserModule extends PathHandler {
|
||||
headers.add("Access-Control-Allow-Origin", url);
|
||||
headers.add("Access-Control-Allow-Headers", "Content-Type");
|
||||
headers.add("Access-Control-Allow-Credentials", "true");
|
||||
headers.add("Access-Control-Allow-Methods","GET, POST, PATCH");
|
||||
}
|
||||
return ex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doOptions(Path path, HttpExchange ex) throws IOException {
|
||||
return sendEmptyResponse(200,addCors(ex));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doGet(Path path, HttpExchange ex) throws IOException {
|
||||
var p = path.toString();
|
||||
@@ -75,6 +68,27 @@ public class UserModule extends PathHandler {
|
||||
return super.doGet(path,ex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doOptions(Path path, HttpExchange ex) throws IOException {
|
||||
return sendEmptyResponse(200,addCors(ex));
|
||||
}
|
||||
|
||||
public boolean doPatch(Path path, HttpExchange ex) throws IOException {
|
||||
addCors(ex);
|
||||
var head = path.pop();
|
||||
try {
|
||||
if (head == null || head.isBlank()) return sendContent(ex,UNPROCESSABLE,"User id missing!");
|
||||
long userId = Long.parseLong(head);
|
||||
var user = users.load(userId);
|
||||
// TODO: update user, then return user data
|
||||
} catch (NumberFormatException e) {
|
||||
return sendContent(ex,UNPROCESSABLE,"Invalid user id: "+head);
|
||||
} catch (UmbrellaException e) {
|
||||
return sendContent(ex,e.statusCode(),e.getMessage());
|
||||
}
|
||||
return super.doPatch(path,ex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doPost(Path path, HttpExchange ex) throws IOException {
|
||||
addCors(ex);
|
||||
|
||||
Reference in New Issue
Block a user