Search in sources :

Example 1 with User

use of com.baidu.disconf.web.service.user.bo.User in project disconf by knightliao.

the class UserController method signin.

/**
     * 登录
     *
     * @param signin
     * @param request
     *
     * @return
     */
@NoAuth
@RequestMapping(value = "/signin", method = RequestMethod.POST)
@ResponseBody
public JsonObjectBase signin(@Valid SigninForm signin, HttpServletRequest request) {
    LOG.info(signin.toString());
    // 验证
    authValidator.validateLogin(signin);
    // 数据库登录
    User user = signMgr.signin(signin.getName());
    // 过期时间
    int expireTime = LoginConstant.SESSION_EXPIRE_TIME;
    if (signin.getRemember().equals(1)) {
        expireTime = LoginConstant.SESSION_EXPIRE_TIME2;
    }
    // redis login
    redisLogin.login(request, user, expireTime);
    VisitorVo visitorVo = userMgr.getCurVisitor();
    return buildSuccess("visitor", visitorVo);
}
Also used : User(com.baidu.disconf.web.service.user.bo.User) VisitorVo(com.baidu.disconf.web.service.user.vo.VisitorVo) NoAuth(com.baidu.dsp.common.annotation.NoAuth) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with User

use of com.baidu.disconf.web.service.user.bo.User 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)

Example 3 with User

use of com.baidu.disconf.web.service.user.bo.User 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 4 with User

use of com.baidu.disconf.web.service.user.bo.User in project disconf by knightliao.

the class SignMgrImpl method signin.

/**
     * 登录
     */
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
@Override
public User signin(String phone) {
    //
    // 获取用户
    //
    User user = userDao.getUserByName(phone);
    userDao.update(user);
    return user;
}
Also used : User(com.baidu.disconf.web.service.user.bo.User) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with User

use of com.baidu.disconf.web.service.user.bo.User in project disconf by knightliao.

the class UserMgrImpl method addOneAppForUser.

/**
     * @param userId
     */
@Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public String addOneAppForUser(Long userId, int appId) {
    User user = getUser(userId);
    String ownAppIds = user.getOwnApps();
    if (ownAppIds.contains(",")) {
        ownAppIds = ownAppIds + "," + appId;
    } else {
        ownAppIds = String.valueOf(appId);
    }
    user.setOwnApps(ownAppIds);
    userDao.update(user);
    return ownAppIds;
}
Also used : User(com.baidu.disconf.web.service.user.bo.User) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

User (com.baidu.disconf.web.service.user.bo.User)8 Visitor (com.baidu.disconf.web.service.user.dto.Visitor)2 ArrayList (java.util.ArrayList)2 Transactional (org.springframework.transaction.annotation.Transactional)2 VisitorVo (com.baidu.disconf.web.service.user.vo.VisitorVo)1 NoAuth (com.baidu.dsp.common.annotation.NoAuth)1 FieldException (com.baidu.dsp.common.exception.FieldException)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1