Search in sources :

Example 1 with Filters

use of org.nutz.mvc.annotation.Filters in project nutz by nutzam.

the class UserModule method login.

@Filters
@POST
@At
public NutMap login(String username, String password, HttpSession session) {
    NutMap re = new NutMap("ok", false);
    if (Strings.isBlank(username) || Strings.isBlank(password)) {
        log.debug("username or password is null");
        return re.setv("msg", "用户名或密码不能为空");
    }
    User user = dao.fetch(User.class, username);
    if (user == null) {
        log.debug("no such user = " + username);
        return re.setv("msg", "没有该用户");
    }
    String tmp = Lang.digest("SHA-256", user.getSalt() + password);
    if (!tmp.equals(user.getPassword())) {
        log.debug("password is wrong");
        return re.setv("msg", "密码错误");
    }
    session.setAttribute("me", user);
    return re.setv("ok", true);
}
Also used : User(net.wendal.nutzdemo.bean.User) NutMap(org.nutz.lang.util.NutMap) Filters(org.nutz.mvc.annotation.Filters) At(org.nutz.mvc.annotation.At) POST(org.nutz.mvc.annotation.POST)

Aggregations

User (net.wendal.nutzdemo.bean.User)1 NutMap (org.nutz.lang.util.NutMap)1 At (org.nutz.mvc.annotation.At)1 Filters (org.nutz.mvc.annotation.Filters)1 POST (org.nutz.mvc.annotation.POST)1