Search in sources :

Example 1 with BindIdValue

use of com.ruoyi.iot.model.login.BindIdValue in project wumei-smart by kerwincui.

the class UserSocialProfileServiceImpl method bindUser.

@Override
public AjaxResult bindUser(String bindId, Long sysUserId) {
    BindIdValue bindValue = redisCache.getCacheObject(BIND_REDIS_KEY + bindId);
    if (bindValue == null) {
        // 不作提示
        return AjaxResult.error(HttpStatus.NO_MESSAGE_ALERT, "未知异常");
    }
    SocialUser socialUser = findSocialUser(bindValue.getUuid(), bindValue.getSource());
    SocialUser updateSocialUser = new SocialUser();
    updateSocialUser.setSocialUserId(socialUser.getSocialUserId());
    updateSocialUser.setSysUserId(sysUserId);
    iSocialUserService.updateSocialUser(updateSocialUser);
    redisCache.deleteObject(BIND_REDIS_KEY + bindId);
    return AjaxResult.success("绑定成功!");
}
Also used : SocialUser(com.ruoyi.iot.domain.SocialUser) BindIdValue(com.ruoyi.iot.model.login.BindIdValue)

Example 2 with BindIdValue

use of com.ruoyi.iot.model.login.BindIdValue in project wumei-smart by kerwincui.

the class SocialLoginServiceImpl method genBindId.

private String genBindId(AuthUser authUser) {
    String bindId = Md5Utils.hash(authUser.getUuid() + authUser.getSource());
    String key = BIND_REDIS_KEY + bindId;
    BindIdValue bindIdValue = new BindIdValue();
    bindIdValue.setSource(authUser.getSource());
    bindIdValue.setUuid(authUser.getUuid());
    redisCache.setCacheObject(key, bindIdValue, BIND_EXPIRE_TIME, TimeUnit.SECONDS);
    return bindId;
}
Also used : BindIdValue(com.ruoyi.iot.model.login.BindIdValue)

Example 3 with BindIdValue

use of com.ruoyi.iot.model.login.BindIdValue in project wumei-smart by kerwincui.

the class SocialLoginServiceImpl method bindLogin.

@Override
public AjaxResult bindLogin(BindLoginBody bindLoginBody) {
    BindIdValue bindValue = redisCache.getCacheObject(BIND_REDIS_KEY + bindLoginBody.getBindId());
    SocialUser socialUser = findSocialUser(bindValue.getUuid(), bindValue.getSource());
    AjaxResult checkAjax = checkSocialUser(socialUser, bindLoginBody.getBindId());
    if (checkAjax != null) {
        return checkAjax;
    }
    AjaxResult ajax = AjaxResult.success();
    // 生成令牌
    String token = sysLoginService.login(bindLoginBody.getUsername(), bindLoginBody.getPassword(), bindLoginBody.getCode(), bindLoginBody.getUuid());
    LoginUser loginUser = tokenService.getLoginUserByToken(token);
    // 绑定和更新
    SocialUser updateSocialUser = new SocialUser();
    updateSocialUser.setSysUserId(loginUser.getUserId());
    updateSocialUser.setSocialUserId(socialUser.getSocialUserId());
    iSocialUserService.updateSocialUser(updateSocialUser);
    ajax.put(Constants.TOKEN, token);
    redisCache.deleteObject(BIND_REDIS_KEY + bindLoginBody.getBindId());
    return ajax;
}
Also used : AjaxResult(com.ruoyi.common.core.domain.AjaxResult) SocialUser(com.ruoyi.iot.domain.SocialUser) LoginUser(com.ruoyi.common.core.domain.model.LoginUser) BindIdValue(com.ruoyi.iot.model.login.BindIdValue)

Example 4 with BindIdValue

use of com.ruoyi.iot.model.login.BindIdValue in project wumei-smart by kerwincui.

the class SocialLoginServiceImpl method checkBindId.

@Override
public AjaxResult checkBindId(String bindId) {
    AjaxResult ajax = AjaxResult.success();
    ajax.put("bindAccount", false);
    if (StringUtils.isEmpty(bindId)) {
        return ajax;
    }
    BindIdValue bindValue = redisCache.getCacheObject(BIND_REDIS_KEY + bindId);
    if (bindValue == null) {
        return ajax;
    }
    ajax.put("bindAccount", true);
    return AjaxResult.success(bindId);
}
Also used : AjaxResult(com.ruoyi.common.core.domain.AjaxResult) BindIdValue(com.ruoyi.iot.model.login.BindIdValue)

Example 5 with BindIdValue

use of com.ruoyi.iot.model.login.BindIdValue in project wumei-smart by kerwincui.

the class SocialLoginServiceImpl method bindRegister.

@Override
public AjaxResult bindRegister(BindRegisterBody bindRegisterBody) {
    if (!("true".equals(iSysConfigService.selectConfigByKey("sys.account.registerUser")))) {
        return error("当前系统没有开启注册功能!");
    }
    BindIdValue bindValue = redisCache.getCacheObject(BIND_REDIS_KEY + bindRegisterBody.getBindId());
    SocialUser socialUser = findSocialUser(bindValue.getUuid(), bindValue.getSource());
    AjaxResult checkAjax = checkSocialUser(socialUser, bindRegisterBody.getBindId());
    if (checkAjax != null) {
        return checkAjax;
    }
    AjaxResult ajax = AjaxResult.success();
    String msg = sysRegisterService.register(bindRegisterBody);
    if (StringUtils.isEmpty(msg)) {
        SysUser sysUser = iSysUserService.selectUserByUserName(bindRegisterBody.getUsername());
        // 绑定和更新
        SocialUser updateSocialUser = new SocialUser();
        updateSocialUser.setSysUserId(sysUser.getUserId());
        updateSocialUser.setSocialUserId(socialUser.getSocialUserId());
        iSocialUserService.updateSocialUser(updateSocialUser);
        redisCache.deleteObject(BIND_REDIS_KEY + bindRegisterBody.getBindId());
    }
    return StringUtils.isEmpty(msg) ? ajax : error(msg);
}
Also used : AjaxResult(com.ruoyi.common.core.domain.AjaxResult) SysUser(com.ruoyi.common.core.domain.entity.SysUser) SocialUser(com.ruoyi.iot.domain.SocialUser) BindIdValue(com.ruoyi.iot.model.login.BindIdValue)

Aggregations

BindIdValue (com.ruoyi.iot.model.login.BindIdValue)5 AjaxResult (com.ruoyi.common.core.domain.AjaxResult)3 SocialUser (com.ruoyi.iot.domain.SocialUser)3 SysUser (com.ruoyi.common.core.domain.entity.SysUser)1 LoginUser (com.ruoyi.common.core.domain.model.LoginUser)1