Search in sources :

Example 1 with LoginIdValue

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

the class SocialLoginServiceImpl method socialLogin.

@Override
public AjaxResult socialLogin(String loginId) {
    AjaxResult ajax = AjaxResult.success();
    String loginKey = LOGIN_SOCIAL_REDIS_KEY + loginId;
    LoginIdValue loginIdValue = redisCache.getCacheObject(loginKey);
    if (loginIdValue != null) {
        // login
        String token = sysLoginService.redirectLogin(loginIdValue.getUsername(), loginIdValue.getPassword());
        ajax.put(Constants.TOKEN, token);
    } else {
        log.info("loginId:{} ", loginId);
        return error(NO_MESSAGE_ALERT, "数据错误");
    }
    return ajax;
}
Also used : AjaxResult(com.ruoyi.common.core.domain.AjaxResult) LoginIdValue(com.ruoyi.iot.model.login.LoginIdValue)

Example 2 with LoginIdValue

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

the class SocialLoginServiceImpl method genLoginId.

private String genLoginId(SysUser sysUser) {
    String loginId = Md5Utils.hash(sysUser.getUserId() + RandomUtil.randomString(32));
    String key = LOGIN_SOCIAL_REDIS_KEY + loginId;
    LoginIdValue loginIdValue = new LoginIdValue();
    loginIdValue.setPassword(sysUser.getPassword());
    loginIdValue.setUsername(sysUser.getUserName());
    redisCache.setCacheObject(key, loginIdValue, LOGIN_SOCIAL_EXPIRE_TIME, TimeUnit.SECONDS);
    return loginId;
}
Also used : LoginIdValue(com.ruoyi.iot.model.login.LoginIdValue)

Aggregations

LoginIdValue (com.ruoyi.iot.model.login.LoginIdValue)2 AjaxResult (com.ruoyi.common.core.domain.AjaxResult)1