projects
/
Sone.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Return an optional Sone from the current session.
[Sone.git]
/
src
/
main
/
java
/
net
/
pterodactylus
/
sone
/
web
/
ajax
/
JsonPage.java
diff --git
a/src/main/java/net/pterodactylus/sone/web/ajax/JsonPage.java
b/src/main/java/net/pterodactylus/sone/web/ajax/JsonPage.java
index
d11cc0d
..
bb32362
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/web/ajax/JsonPage.java
+++ b/
src/main/java/net/pterodactylus/sone/web/ajax/JsonPage.java
@@
-36,6
+36,7
@@
import net.pterodactylus.util.web.Page;
import net.pterodactylus.util.web.Response;
import com.fasterxml.jackson.databind.ObjectMapper;
import net.pterodactylus.util.web.Response;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.Optional;
import freenet.clients.http.ToadletContext;
import freenet.clients.http.ToadletContext;
@@
-84,7
+85,7
@@
public abstract class JsonPage implements FreenetPage {
* @return The currently logged in Sone, or {@code null} if no Sone is
* currently logged in
*/
* @return The currently logged in Sone, or {@code null} if no Sone is
* currently logged in
*/
- protected
Sone
getCurrentSone(ToadletContext toadletContext) {
+ protected
Optional<Sone>
getCurrentSone(ToadletContext toadletContext) {
return webInterface.getCurrentSone(toadletContext);
}
return webInterface.getCurrentSone(toadletContext);
}
@@
-99,7
+100,7
@@
public abstract class JsonPage implements FreenetPage {
* @return The currently logged in Sone, or {@code null} if no Sone is
* currently logged in
*/
* @return The currently logged in Sone, or {@code null} if no Sone is
* currently logged in
*/
- protected
Sone
getCurrentSone(ToadletContext toadletContext, boolean create) {
+ protected
Optional<Sone>
getCurrentSone(ToadletContext toadletContext, boolean create) {
return webInterface.getCurrentSone(toadletContext, create);
}
return webInterface.getCurrentSone(toadletContext, create);
}
@@
-199,7
+200,7
@@
public abstract class JsonPage implements FreenetPage {
}
}
if (requiresLogin()) {
}
}
if (requiresLogin()) {
- if (
getCurrentSone(request.getToadletContext(), false) == null
) {
+ if (
!getCurrentSone(request.getToadletContext(), false).isPresent()
) {
return response.setStatusCode(403).setStatusText("Forbidden").setContentType("application/json").write(objectMapper.writeValueAsString(new JsonErrorReturnObject("auth-required")));
}
}
return response.setStatusCode(403).setStatusText("Forbidden").setContentType("application/json").write(objectMapper.writeValueAsString(new JsonErrorReturnObject("auth-required")));
}
}