@Override
@Nullable
- public Sone getCurrentSone(@Nonnull ToadletContext toadletContext, boolean createSession) {
- return createSession ? getCurrentSoneCreatingSession(toadletContext) : getCurrentSoneWithoutCreatingSession(toadletContext);
+ public Sone getCurrentSone(@Nonnull ToadletContext toadletContext) {
+ return getCurrentSoneWithoutCreatingSession(toadletContext);
}
/**
*/
interface SessionProvider {
- fun getCurrentSone(toadletContext: ToadletContext, createSession: Boolean = true): Sone?
+ fun getCurrentSone(toadletContext: ToadletContext): Sone?
fun setCurrentSone(toadletContext: ToadletContext, sone: Sone?)
}
JsonErrorReturnObject(error)
protected fun getCurrentSone(toadletContext: ToadletContext, createSession: Boolean = true) =
- sessionProvider.getCurrentSone(toadletContext, createSession)
+ sessionProvider.getCurrentSone(toadletContext)
override fun handleRequest(request: FreenetRequest, response: Response): Response {
if (core.preferences.requireFullAccess && !request.toadletContext.isAllowedFullAccess) {
if (needsFormPassword && request.parameters["formPassword"] != webInterface.formPassword) {
return response.setStatusCode(403).setStatusText("Forbidden").setContentType("application/json").write(createErrorJsonObject("auth-required").asJsonString())
}
- if (requiresLogin && (sessionProvider.getCurrentSone(request.toadletContext, false) == null)) {
+ if (requiresLogin && (sessionProvider.getCurrentSone(request.toadletContext) == null)) {
return response.setStatusCode(403).setStatusText("Forbidden").setContentType("application/json").write(createErrorJsonObject("auth-required").asJsonString())
}
return try {
protected val translation: Translation = webInterface.translation
protected fun getCurrentSone(toadletContext: ToadletContext, createSession: Boolean = true) =
- sessionProvider.getCurrentSone(toadletContext, createSession)
+ sessionProvider.getCurrentSone(toadletContext)
protected fun setCurrentSone(toadletContext: ToadletContext, sone: Sone?) =
sessionProvider.setCurrentSone(toadletContext, sone)
init {
whenever(webInterface.templateContextFactory).thenReturn(TemplateContextFactory())
- whenever(webInterface.getCurrentSone(ArgumentMatchers.eq(toadletContext), ArgumentMatchers.anyBoolean())).thenReturn(currentSone)
+ whenever(webInterface.getCurrentSone(ArgumentMatchers.eq(toadletContext))).thenReturn(currentSone)
whenever(webInterface.getCurrentSoneCreatingSession(toadletContext)).thenReturn(currentSone)
whenever(webInterface.getCurrentSoneWithoutCreatingSession(toadletContext)).thenReturn(currentSone)
whenever(webInterface.core).thenReturn(core)
}
protected fun unsetCurrentSone() {
- whenever(webInterface.getCurrentSone(ArgumentMatchers.eq(toadletContext), ArgumentMatchers.anyBoolean())).thenReturn(null)
+ whenever(webInterface.getCurrentSone(ArgumentMatchers.eq(toadletContext))).thenReturn(null)
whenever(webInterface.getCurrentSoneWithoutCreatingSession(toadletContext)).thenReturn(null)
whenever(webInterface.getCurrentSoneCreatingSession(toadletContext)).thenReturn(null)
}
private fun setupWebInterface() {
whenever(webInterface.getCurrentSoneCreatingSession(eq(toadletContext))).thenReturn(currentSone)
- whenever(webInterface.getCurrentSone(eq(toadletContext), anyBoolean())).thenReturn(currentSone)
+ whenever(webInterface.getCurrentSone(eq(toadletContext))).thenReturn(currentSone)
whenever(webInterface.getCurrentSoneWithoutCreatingSession(eq(toadletContext))).thenReturn(currentSone)
whenever(webInterface.getNotifications(currentSone)).then { notifications.values }
whenever(webInterface.getNotification(anyString())).then { notifications[it[0]].asOptional() }
fun unsetCurrentSone() {
whenever(webInterface.getCurrentSoneCreatingSession(eq(toadletContext))).thenReturn(null)
- whenever(webInterface.getCurrentSone(eq(toadletContext), anyBoolean())).thenReturn(null)
+ whenever(webInterface.getCurrentSone(eq(toadletContext))).thenReturn(null)
whenever(webInterface.getCurrentSoneWithoutCreatingSession(eq(toadletContext))).thenReturn(null)
}