Search in sources :

Example 1 with EzyRequestAppParams

use of com.tvd12.ezyfoxserver.request.EzyRequestAppParams 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

EzyApplication (com.tvd12.ezyfoxserver.EzyApplication)1 EzyAppRequestController (com.tvd12.ezyfoxserver.app.EzyAppRequestController)1 EzyAppContext (com.tvd12.ezyfoxserver.context.EzyAppContext)1 EzySession (com.tvd12.ezyfoxserver.entity.EzySession)1 EzyUser (com.tvd12.ezyfoxserver.entity.EzyUser)1 EzyUserRequestAppEvent (com.tvd12.ezyfoxserver.event.EzyUserRequestAppEvent)1 EzyRequestAppParams (com.tvd12.ezyfoxserver.request.EzyRequestAppParams)1 EzyUserManager (com.tvd12.ezyfoxserver.wrapper.EzyUserManager)1