Search in sources :

Example 6 with EzyAppRequestController

use of com.tvd12.ezyfoxserver.app.EzyAppRequestController in project ezyfox-server by youngmonkeys.

the class EzyRequestAppController method handle.

@Override
public void handle(EzyServerContext ctx, EzyRequestAppRequest request) {
    EzyRequestAppParams params = request.getParams();
    EzyAppContext appCtx = ctx.getAppContext(params.getAppId());
    EzyApplication app = appCtx.getApp();
    EzyAppRequestController requestController = app.getRequestController();
    // user manager for checking, user must be managed
    EzyUserManager userManger = appCtx.getApp().getUserManager();
    EzyUser user = request.getUser();
    // check user joined app or not to prevent spam request
    boolean hasAccessed = userManger.containsUser(user);
    if (hasAccessed) {
        // redirect handling to app
        EzyUserRequestAppEvent event = newRequestAppEvent(request);
        requestController.handle(appCtx, event);
    } else {
        EzySession session = request.getSession();
        responseRequestAppError(ctx, session);
    }
}
Also used : EzyApplication(com.tvd12.ezyfoxserver.EzyApplication) EzyUser(com.tvd12.ezyfoxserver.entity.EzyUser) EzyRequestAppParams(com.tvd12.ezyfoxserver.request.EzyRequestAppParams) EzyAppContext(com.tvd12.ezyfoxserver.context.EzyAppContext) EzyAppRequestController(com.tvd12.ezyfoxserver.app.EzyAppRequestController) EzyUserManager(com.tvd12.ezyfoxserver.wrapper.EzyUserManager) EzyUserRequestAppEvent(com.tvd12.ezyfoxserver.event.EzyUserRequestAppEvent) EzySession(com.tvd12.ezyfoxserver.entity.EzySession)

Aggregations

EzyAppRequestController (com.tvd12.ezyfoxserver.app.EzyAppRequestController)6 EzySimpleApplication (com.tvd12.ezyfoxserver.EzySimpleApplication)4 EzyUserRequestAppEvent (com.tvd12.ezyfoxserver.event.EzyUserRequestAppEvent)4 EzyArray (com.tvd12.ezyfox.entity.EzyArray)3 EzyAbstractSession (com.tvd12.ezyfoxserver.entity.EzyAbstractSession)3 EzySimpleUser (com.tvd12.ezyfoxserver.entity.EzySimpleUser)3 EzySimpleUserRequestAppEvent (com.tvd12.ezyfoxserver.event.EzySimpleUserRequestAppEvent)3 EzyApplication (com.tvd12.ezyfoxserver.EzyApplication)1 EzyAppSetup (com.tvd12.ezyfoxserver.command.EzyAppSetup)1 EzyAppContext (com.tvd12.ezyfoxserver.context.EzyAppContext)1 EzySession (com.tvd12.ezyfoxserver.entity.EzySession)1 EzyUser (com.tvd12.ezyfoxserver.entity.EzyUser)1 EzyRequestAppParams (com.tvd12.ezyfoxserver.request.EzyRequestAppParams)1 EzySimpleAppSetting (com.tvd12.ezyfoxserver.setting.EzySimpleAppSetting)1 EzyCommandsAware (com.tvd12.ezyfoxserver.support.controller.EzyCommandsAware)1 EzyUserManager (com.tvd12.ezyfoxserver.wrapper.EzyUserManager)1 BaseTest (com.tvd12.test.base.BaseTest)1 Test (org.testng.annotations.Test)1