mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 13:10:44 +00:00
explicit errors if context isn't setup
This commit is contained in:
@ -25,9 +25,12 @@ package com.kingsrook.qqq.backend.core.actions;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
import com.kingsrook.qqq.backend.core.context.QContext;
|
||||||
import com.kingsrook.qqq.backend.core.exceptions.QAuthenticationException;
|
import com.kingsrook.qqq.backend.core.exceptions.QAuthenticationException;
|
||||||
import com.kingsrook.qqq.backend.core.exceptions.QException;
|
import com.kingsrook.qqq.backend.core.exceptions.QException;
|
||||||
import com.kingsrook.qqq.backend.core.model.actions.AbstractActionInput;
|
import com.kingsrook.qqq.backend.core.model.actions.AbstractActionInput;
|
||||||
|
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
|
||||||
|
import com.kingsrook.qqq.backend.core.model.session.QSession;
|
||||||
import com.kingsrook.qqq.backend.core.modules.authentication.QAuthenticationModuleDispatcher;
|
import com.kingsrook.qqq.backend.core.modules.authentication.QAuthenticationModuleDispatcher;
|
||||||
import com.kingsrook.qqq.backend.core.modules.authentication.QAuthenticationModuleInterface;
|
import com.kingsrook.qqq.backend.core.modules.authentication.QAuthenticationModuleInterface;
|
||||||
|
|
||||||
@ -43,9 +46,22 @@ public class ActionHelper
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
public static void validateSession(AbstractActionInput request) throws QException
|
public static void validateSession(AbstractActionInput request) throws QException
|
||||||
{
|
{
|
||||||
|
QInstance qInstance = QContext.getQInstance();
|
||||||
|
QSession qSession = QContext.getQSession();
|
||||||
|
|
||||||
|
if(qInstance == null)
|
||||||
|
{
|
||||||
|
throw (new QException("QInstance was not set in QContext."));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(qSession == null)
|
||||||
|
{
|
||||||
|
throw (new QException("QSession was not set in QContext."));
|
||||||
|
}
|
||||||
|
|
||||||
QAuthenticationModuleDispatcher qAuthenticationModuleDispatcher = new QAuthenticationModuleDispatcher();
|
QAuthenticationModuleDispatcher qAuthenticationModuleDispatcher = new QAuthenticationModuleDispatcher();
|
||||||
QAuthenticationModuleInterface authenticationModule = qAuthenticationModuleDispatcher.getQModule(request.getAuthenticationMetaData());
|
QAuthenticationModuleInterface authenticationModule = qAuthenticationModuleDispatcher.getQModule(qInstance.getAuthentication());
|
||||||
if(!authenticationModule.isSessionValid(request.getInstance(), request.getSession()))
|
if(!authenticationModule.isSessionValid(qInstance, qSession))
|
||||||
{
|
{
|
||||||
throw new QAuthenticationException("Invalid session in request");
|
throw new QAuthenticationException("Invalid session in request");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user