Search in sources :

Example 1 with SysAppClientId

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()));
        }
    }
}
Also used : SysAppClient(com.publiccms.entities.sys.SysAppClient) SysAppClientId(com.publiccms.entities.sys.SysAppClientId)

Example 2 with SysAppClientId

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);
}
Also used : SysAppClientId(com.publiccms.entities.sys.SysAppClientId)

Example 3 with SysAppClientId

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);
}
Also used : SysAppClientId(com.publiccms.entities.sys.SysAppClientId)

Example 4 with SysAppClientId

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();
    }
}
Also used : SysAppClient(com.publiccms.entities.sys.SysAppClient) SysAppClientId(com.publiccms.entities.sys.SysAppClientId)

Example 5 with SysAppClientId

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);
}
Also used : SysUserToken(com.publiccms.entities.sys.SysUserToken) LogLogin(com.publiccms.entities.log.LogLogin) SysAppClient(com.publiccms.entities.sys.SysAppClient) SysAppClientId(com.publiccms.entities.sys.SysAppClientId) SysSite(com.publiccms.entities.sys.SysSite)

Aggregations

SysAppClientId (com.publiccms.entities.sys.SysAppClientId)5 SysAppClient (com.publiccms.entities.sys.SysAppClient)3 LogLogin (com.publiccms.entities.log.LogLogin)1 SysSite (com.publiccms.entities.sys.SysSite)1 SysUserToken (com.publiccms.entities.sys.SysUserToken)1