implemented page view for freely available wiki pages

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2025-09-19 20:45:54 +02:00
parent 93124a9a8c
commit 60d116664b
3 changed files with 62 additions and 4 deletions

View File

@@ -70,11 +70,16 @@ public class WikiModule extends BaseHandler implements WikiService {
try {
Optional<Token> token = SessionToken.from(ex).map(Token::of);
var user = userService().loadUser(token);
if (user.isEmpty()) return unauthorized(ex);
var head = path.pop();
if (user.isEmpty()) {
return switch (head){
case PAGE -> getPage(path, null, ex);
case null, default -> unauthorized(ex);
};
}
return switch (head) {
case null -> getUserPages(user.get(),ex);
case AVAILABLE -> getAvailability(path,ex);
case AVAILABLE -> getAvailability(path,ex);
case PAGE -> getPage(path, user.get(), ex);
default -> super.doGet(path,ex);
};
@@ -143,7 +148,8 @@ public class WikiModule extends BaseHandler implements WikiService {
}
}
var page = loadPage(id,version);
var permission = page.members().get(user.id());
var userId = user == null ? 0 : user.id();
var permission = page.members().get(userId);
if (permission == null) throw forbidden("You are not allowed to access \"{0}\"!",id);
return sendContent(ex, page);
}