/**
* @Description:设置密码并激活账号
*/
@At("/auth/active")
@Ok("re")
public String active(@Param("token")String token, HttpSession session){
if (Strings.isBlank(token)) {
return "请不要直接访问这个链接!!!";
}
if (token.length() < 10) {
return "非法token";
}
try {
token = Toolkit._3DES_decode(emailKEY, Toolkit.hexstr2bytearray(token));
if (token == null)
return "非法token";
String[] tmp = token.split(",", 3);
if (tmp.length != 3 || tmp[0].length() == 0 || tmp[1].length() == 0 || tmp[2].length() == 0)
return "非法token";
long time = Long.parseLong(tmp[2]);
if (System.currentTimeMillis() - time > 30*60*1000) {
return "该验证链接已经超时";
}
String userId = tmp[0];
Cnd cnd = Cnd.where("id", "=", userId).and("email", "=", tmp[1]);
int re = userService.update( Chain.make("isActivate", true), cnd);
if (re == 1) {
// 设置密码并激活账户
return "beetl:app/setpasw.html";
}
return "验证失败!!请重新验证!!";
} catch (Throwable e) {
log.debug("检查token时出错", e);
return "非法token";
}
}
添加回复
请先登陆