use of com.publiccms.entities.sys.SysAppClientId in project PublicCMS-preview by sanluan.
the class AppClientDirective method execute.
@Override
public void execute(RenderHandler handler, SysApp app, SysUser user) throws IOException, Exception {
String uuid = handler.getString("uuid");
String clientVersion = handler.getString("clientVersion");
if (CommonUtils.notEmpty(uuid)) {
SysAppClientId sysAppClientId = new SysAppClientId(getSite(handler).getId(), app.getChannel(), uuid);
SysAppClient appClient = appClientService.getEntity(sysAppClientId);
if (null == appClient) {
appClient = new SysAppClient(sysAppClientId, CommonUtils.getDate(), false);
appClient.setClientVersion(clientVersion);
appClient.setLastLoginIp(RequestUtils.getIpAddress(handler.getRequest()));
appClientService.save(appClient);
} else {
appClientService.updateLastLogin(sysAppClientId, clientVersion, RequestUtils.getIpAddress(handler.getRequest()));
}
}
}
use of com.publiccms.entities.sys.SysAppClientId in project PublicCMS-preview by sanluan.
the class BindingUserDirective method execute.
@Override
public void execute(RenderHandler handler, SysApp app, SysUser user) throws IOException, Exception {
String uuid = handler.getString("uuid");
boolean result = false;
if (CommonUtils.notEmpty(uuid)) {
SysAppClientId sysAppClientId = new SysAppClientId(getSite(handler).getId(), app.getChannel(), uuid);
appClientService.updateUser(sysAppClientId, user.getId());
result = true;
}
handler.put("result", result);
}
use of com.publiccms.entities.sys.SysAppClientId in project PublicCMS-preview by sanluan.
the class UnBindingUserDirective method execute.
@Override
public void execute(RenderHandler handler, SysApp app, SysUser user) throws IOException, Exception {
String uuid = handler.getString("uuid");
boolean result = false;
if (CommonUtils.notEmpty(uuid)) {
SysAppClientId sysAppClientId = new SysAppClientId(getSite(handler).getId(), app.getChannel(), uuid);
appClientService.updateUser(sysAppClientId, null);
result = true;
}
handler.put("result", result);
}
use of com.publiccms.entities.sys.SysAppClientId in project PublicCMS-preview by sanluan.
the class CreateAppClientDirective method execute.
@Override
public void execute(RenderHandler handler) throws IOException, Exception {
String uuid = handler.getString("uuid");
String channel = handler.getString("channel");
Long userId = handler.getLong("userId");
if (CommonUtils.notEmpty(uuid) && CommonUtils.notEmpty(channel)) {
SysAppClientId sysAppClientId = new SysAppClientId(getSite(handler).getId(), channel, uuid);
SysAppClient appClient = appClientService.getEntity(sysAppClientId);
if (null == appClient) {
appClient = new SysAppClient(sysAppClientId, CommonUtils.getDate(), false);
appClient.setClientVersion(uuid);
appClient.setLastLoginIp(RequestUtils.getIpAddress(handler.getRequest()));
if (CommonUtils.notEmpty(userId)) {
appClient.setUserId(userId);
}
appClientService.save(appClient);
} else {
appClientService.updateLastLogin(sysAppClientId, uuid, RequestUtils.getIpAddress(handler.getRequest()));
appClientService.updateUser(sysAppClientId, userId);
}
handler.render();
}
}
use of com.publiccms.entities.sys.SysAppClientId in project PublicCMS-preview by sanluan.
the class AutoLoginDirective method execute.
@Override
public void execute(RenderHandler handler, SysApp app, SysUser user) throws IOException, Exception {
String uuid = handler.getString("uuid");
boolean result = false;
if (CommonUtils.notEmpty(uuid)) {
SysSite site = getSite(handler);
SysAppClientId sysAppClientId = new SysAppClientId(site.getId(), app.getChannel(), uuid);
SysAppClient appClient = appClientService.getEntity(sysAppClientId);
if (null != appClient && CommonUtils.notEmpty(appClient.getUserId())) {
user = service.getEntity(appClient.getUserId());
if (null != user && !user.isDisabled()) {
String authToken = UUID.randomUUID().toString();
String ip = RequestUtils.getIpAddress(handler.getRequest());
sysUserTokenService.save(new SysUserToken(authToken, site.getId(), user.getId(), app.getChannel(), CommonUtils.getDate(), ip));
service.updateLoginStatus(user.getId(), ip);
logLoginService.save(new LogLogin(site.getId(), uuid, user.getId(), ip, app.getChannel(), true, CommonUtils.getDate(), null));
user.setPassword(null);
result = true;
handler.put("authToken", authToken).put("user", user);
}
}
}
handler.put("result", result);
}
Aggregations