use of com.tvd12.ezyfoxserver.response.EzyLoginParams in project ezyfox-server by youngmonkeys.
the class EzyLoginControllerTest method testSetUserProperties.
@Test
public void testSetUserProperties() {
EzySimpleServerContext ctx = (EzySimpleServerContext) newServerContext();
EzySimpleServer server = (EzySimpleServer) ctx.getServer();
server.setResponseApi(mock(EzyResponseApi.class));
EzySession session = newSession();
session.setToken("abcdef");
EzyArray data = newLoginData();
EzySimpleLoginRequest request = new EzySimpleLoginRequest();
request.deserializeParams(data);
request.setSession(session);
EzyLoginProcessor processor = new EzyLoginProcessor(ctx);
EzyZoneContext zoneContext = ctx.getZoneContext("example");
EzyLoginParams params = request.getParams();
EzySimpleUserLoginEvent event = new EzySimpleUserLoginEvent(session, params.getZoneName(), params.getUsername(), params.getPassword(), params.getData());
event.setUserProperty("dataId", 123L);
processor.apply(zoneContext, event);
event.release();
EzyZoneUserManager userManager = zoneContext.getZone().getUserManager();
EzyUser user = userManager.getUser("dungtv");
assert user.getProperty("dataId").equals(123L);
}
use of com.tvd12.ezyfoxserver.response.EzyLoginParams in project ezyfox-server by youngmonkeys.
the class EzyLoginResponseTest method test.
@Test
public void test() {
EzyArray data = EzyEntityFactory.EMPTY_ARRAY;
EzyLoginParams params = new EzyLoginParams();
params.setZoneId(1);
params.setZoneName("test");
params.setUserId(2);
params.setData(data);
params.setUsername("name");
assert params.getZoneId() == 1;
assert params.getZoneName().equals("test");
assert params.getUserId() == 2;
assert params.getData() == data;
assert params.getUsername().equals("name");
EzyLoginResponse response = new EzyLoginResponse(params);
assert response.getParams() == params;
response.release();
}
use of com.tvd12.ezyfoxserver.response.EzyLoginParams in project ezyfox-server by youngmonkeys.
the class EzyLoginController method handle.
@Override
public void handle(EzyServerContext ctx, EzyLoginRequest request) {
try {
EzySession session = request.getSession();
EzyLoginParams params = request.getParams();
EzyZoneContext zoneContext = ctx.getZoneContext(params.getZoneName());
EzyUserLoginEvent loginEvent = newLoginEvent(session, params);
try {
control(ctx, zoneContext, loginEvent);
} finally {
loginEvent.release();
}
} catch (EzyLoginErrorException e) {
processException(ctx, request.getSession(), e);
throw e;
} catch (EzyMaxUserException e) {
processException(ctx, request.getSession(), maximumUsers(e));
throw e;
} catch (EzyZoneNotFoundException e) {
processException(ctx, request.getSession(), zoneNotFound(e));
throw e;
} catch (Exception e) {
processException(ctx, request.getSession(), serverError(e));
throw e;
}
}
use of com.tvd12.ezyfoxserver.response.EzyLoginParams in project ezyfox-server by youngmonkeys.
the class EzyLoginProcessor method newLoginResponse.
protected EzyResponse newLoginResponse(EzyZoneContext zoneContext, EzyUser user, EzyData loginOutputData) {
EzyZoneSetting zoneSetting = getZoneSetting(zoneContext);
EzyLoginParams params = new EzyLoginParams();
params.setData(loginOutputData);
params.setUserId(user.getId());
params.setUsername(user.getName());
params.setZoneId(zoneSetting.getId());
params.setZoneName(zoneSetting.getName());
return new EzyLoginResponse(params);
}
Aggregations