Search in sources :

Example 6 with Visitor

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;
}
Also used : Visitor(com.baidu.disconf.web.service.user.dto.Visitor) VisitorVo(com.baidu.disconf.web.service.user.vo.VisitorVo)

Example 7 with Visitor

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);
}
Also used : Visitor(com.baidu.disconf.web.service.user.dto.Visitor) ConfigHistory(com.baidu.disconf.web.service.config.bo.ConfigHistory) Date(java.util.Date)

Example 8 with Visitor

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);
    }
}
Also used : User(com.baidu.disconf.web.service.user.bo.User) FieldException(com.baidu.dsp.common.exception.FieldException) Visitor(com.baidu.disconf.web.service.user.dto.Visitor)

Example 9 with Visitor

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("修改成功,请重新登录");
}
Also used : Visitor(com.baidu.disconf.web.service.user.dto.Visitor) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 10 with Visitor

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;
}
Also used : User(com.baidu.disconf.web.service.user.bo.User) Visitor(com.baidu.disconf.web.service.user.dto.Visitor)

Aggregations

Visitor (com.baidu.disconf.web.service.user.dto.Visitor)12 User (com.baidu.disconf.web.service.user.bo.User)2 RequestMethod (org.springframework.web.bind.annotation.RequestMethod)2 ConfigHistory (com.baidu.disconf.web.service.config.bo.ConfigHistory)1 VisitorVo (com.baidu.disconf.web.service.user.vo.VisitorVo)1 AccessDeniedException (com.baidu.dsp.common.exception.AccessDeniedException)1 FieldException (com.baidu.dsp.common.exception.FieldException)1 InetAddress (java.net.InetAddress)1 UnknownHostException (java.net.UnknownHostException)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 HttpSession (javax.servlet.http.HttpSession)1 Around (org.aspectj.lang.annotation.Around)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1