use of com.ruoyi.common.core.domain.model.LoginUser in project wumei-smart by kerwincui.
the class SysProfileController method profile.
/**
* 个人信息
*/
@GetMapping
public AjaxResult profile() {
LoginUser loginUser = getLoginUser();
SysUser user = loginUser.getUser();
AjaxResult ajax = AjaxResult.success(user);
ajax.put("roleGroup", userService.selectUserRoleGroup(loginUser.getUsername()));
ajax.put("postGroup", userService.selectUserPostGroup(loginUser.getUsername()));
ajax.put("socialGroup", iUserSocialProfileService.selectUserSocialProfile(loginUser.getUserId()));
return ajax;
}
use of com.ruoyi.common.core.domain.model.LoginUser 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;
}
use of com.ruoyi.common.core.domain.model.LoginUser in project RuoYi-Vue by yangzongzhuan.
the class SysProfileController method updatePwd.
/**
* 重置密码
*/
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PutMapping("/updatePwd")
public AjaxResult updatePwd(String oldPassword, String newPassword) {
LoginUser loginUser = getLoginUser();
String userName = loginUser.getUsername();
String password = loginUser.getPassword();
if (!SecurityUtils.matchesPassword(oldPassword, password)) {
return AjaxResult.error("修改密码失败,旧密码错误");
}
if (SecurityUtils.matchesPassword(newPassword, password)) {
return AjaxResult.error("新密码不能与旧密码相同");
}
if (userService.resetUserPwd(userName, SecurityUtils.encryptPassword(newPassword)) > 0) {
// 更新缓存用户密码
loginUser.getUser().setPassword(SecurityUtils.encryptPassword(newPassword));
tokenService.setLoginUser(loginUser);
return AjaxResult.success();
}
return AjaxResult.error("修改密码异常,请联系管理员");
}
use of com.ruoyi.common.core.domain.model.LoginUser in project RuoYi-Vue by yangzongzhuan.
the class LogAspect method handleLog.
protected void handleLog(final JoinPoint joinPoint, Log controllerLog, final Exception e, Object jsonResult) {
try {
// 获取当前的用户
LoginUser loginUser = SecurityUtils.getLoginUser();
// *========数据库日志=========*//
SysOperLog operLog = new SysOperLog();
operLog.setStatus(BusinessStatus.SUCCESS.ordinal());
// 请求的地址
String ip = IpUtils.getIpAddr(ServletUtils.getRequest());
operLog.setOperIp(ip);
operLog.setOperUrl(ServletUtils.getRequest().getRequestURI());
if (loginUser != null) {
operLog.setOperName(loginUser.getUsername());
}
if (e != null) {
operLog.setStatus(BusinessStatus.FAIL.ordinal());
operLog.setErrorMsg(StringUtils.substring(e.getMessage(), 0, 2000));
}
// 设置方法名称
String className = joinPoint.getTarget().getClass().getName();
String methodName = joinPoint.getSignature().getName();
operLog.setMethod(className + "." + methodName + "()");
// 设置请求方式
operLog.setRequestMethod(ServletUtils.getRequest().getMethod());
// 处理设置注解上的参数
getControllerMethodDescription(joinPoint, controllerLog, operLog, jsonResult);
// 保存数据库
AsyncManager.me().execute(AsyncFactory.recordOper(operLog));
} catch (Exception exp) {
// 记录本地异常日志
log.error("==前置通知异常==");
log.error("异常信息:{}", exp.getMessage());
exp.printStackTrace();
}
}
use of com.ruoyi.common.core.domain.model.LoginUser in project RuoYi-Vue by yangzongzhuan.
the class TokenService method getLoginUser.
/**
* 获取用户身份信息
*
* @return 用户信息
*/
public LoginUser getLoginUser(HttpServletRequest request) {
// 获取请求携带的令牌
String token = getToken(request);
if (StringUtils.isNotEmpty(token)) {
try {
Claims claims = parseToken(token);
// 解析对应的权限以及用户信息
String uuid = (String) claims.get(Constants.LOGIN_USER_KEY);
String userKey = getTokenKey(uuid);
LoginUser user = redisCache.getCacheObject(userKey);
return user;
} catch (Exception e) {
}
}
return null;
}
Aggregations