use of com.baidu.disconf.web.service.user.dto.Visitor in project disconf by knightliao.
the class UserMgrImpl method getCurVisitor.
@Override
public VisitorVo getCurVisitor() {
Visitor visitor = ThreadContext.getSessionVisitor();
if (visitor == null) {
return null;
}
VisitorVo visitorVo = new VisitorVo();
visitorVo.setId(visitor.getId());
visitorVo.setName(visitor.getLoginUserName());
return visitorVo;
}
use of com.baidu.disconf.web.service.user.dto.Visitor in project disconf by knightliao.
the class ConfigHistoryMgrImpl method createOne.
@Override
public void createOne(Long configId, String oldValue, String newValue) {
ConfigHistory configHistory = new ConfigHistory();
configHistory.setConfigId(configId);
configHistory.setOldValue(oldValue);
configHistory.setNewValue(newValue);
Visitor visitor = ThreadContext.getSessionVisitor();
if (visitor != null) {
configHistory.setUpdateBy(visitor.getLoginUserId());
}
String curTime = DateUtils.format(new Date(), DataFormatConstants.COMMON_TIME_FORMAT);
configHistory.setCreateTime(curTime);
configHistoryDao.create(configHistory);
}
use of com.baidu.disconf.web.service.user.dto.Visitor in project disconf by knightliao.
the class AuthValidator method validatePasswordModify.
/**
* 验证密码更新
*/
public void validatePasswordModify(PasswordModifyForm passwordModifyForm) {
Visitor visitor = ThreadContext.getSessionVisitor();
User user = userMgr.getUser(visitor.getLoginUserId());
// 校验密码
if (!signMgr.validate(user.getPassword(), passwordModifyForm.getOld_password())) {
throw new FieldException(PasswordModifyForm.OLD_PASSWORD, "password.not.right", null);
}
if (!passwordModifyForm.getNew_password().equals(passwordModifyForm.getNew_password_2())) {
throw new FieldException(PasswordModifyForm.NEW_PASSWORD, "two.password.not.equal", null);
}
}
use of com.baidu.disconf.web.service.user.dto.Visitor in project disconf by knightliao.
the class UserController method password.
/**
* 修改密码
*
* @param
*
* @return
*/
@RequestMapping(value = "/password", method = RequestMethod.PUT)
@ResponseBody
public JsonObjectBase password(@Valid PasswordModifyForm passwordModifyForm, HttpServletRequest request) {
// 校验
authValidator.validatePasswordModify(passwordModifyForm);
// 修改
Visitor visitor = ThreadContext.getSessionVisitor();
userMgr.modifyPassword(visitor.getLoginUserId(), passwordModifyForm.getNew_password());
// re login
redisLogin.logout(request);
return buildSuccess("修改成功,请重新登录");
}
use of com.baidu.disconf.web.service.user.dto.Visitor in project disconf by knightliao.
the class RedisLoginImplMock method isLogin.
/**
* 校验Redis是否登录
*/
@Override
public Visitor isLogin(HttpServletRequest request) {
Long userId = 1L;
User user = userMgr.getUser(userId);
Visitor visitor = new Visitor();
visitor.setId(userId);
visitor.setLoginUserId(userId);
visitor.setLoginUserName(user.getName());
return visitor;
}
Aggregations