NutzCN Logo
问答 emailKEY爆红。就吃了一顿饭回来就爆红了
发布于 1714天前 作者 wx_p064hjeoh9l2g0cqspro 1193 次浏览 复制 上一个帖子 下一个帖子
标签:

@At("/active/mail")
@POST
public Object activeMail(@Attr(scope=Scope.SESSION, value="me")int userId,
HttpServletRequest req) {
NutMap re = new NutMap();
UserProfile profile = get(userId);
if (Strings.isBlank(profile.getEmail())) {
return re.setv("ok", false).setv("msg", "你还没有填邮箱啊!");
}
String token = String.format("%s,%s,%s", userId, profile.getEmail(), System.currentTimeMillis());
token = Toolkit._3DES_encode(emailKEY, token.getBytes());
String url = req.getRequestURL() + "?token=" + token;
String html = "如果无法点击,请拷贝一下链接到浏览器中打开验证链接 %s";
html = String.format(html, url, url);
try {
boolean ok = emailService.send(profile.getEmail(), "XXX 验证邮件 by Nutzbook", html);
if (!ok) {
return re.setv("ok", false).setv("msg", "发送失败");
}
} catch (Throwable e) {
log.debug("发送邮件失败", e);
return re.setv("ok", false).setv("msg", "发送失败");
}
return re.setv("ok", true);
}

8 回复

。。。 又不看发帖提示的

@At("/active/mail")
    @POST
    public Object activeMail(@Attr(scope=Scope.SESSION, value="me")int userId,
                             HttpServletRequest req) {
        NutMap re = new NutMap();
        UserProfile profile = get(userId);
        if (Strings.isBlank(profile.getEmail())) {
            return re.setv("ok", false).setv("msg", "你还没有填邮箱啊!");
        }
        String token = String.format("%s,%s,%s", userId, profile.getEmail(), System.currentTimeMillis());
        token = Toolkit._3DES_encode(emailKEY, token.getBytes());
        String url = req.getRequestURL() + "?token=" + token;
        String html = "<div>如果无法点击,请拷贝一下链接到浏览器中打开<p/>验证链接 %s</div>";
        html = String.format(html, url, url);
        try {
            boolean ok = emailService.send(profile.getEmail(), "XXX 验证邮件 by Nutzbook", html);
            if (!ok) {
                return re.setv("ok", false).setv("msg", "发送失败");
            }
        } catch (Throwable e) {
            log.debug("发送邮件失败", e);
            return re.setv("ok", false).setv("msg", "发送失败");
        }
        return re.setv("ok", true);
    }

这样吗?

我找了一个小时了。。还是没找到。。

爆红是啥意思? 编译错误? emailKEY未声明?

Error:(141, 38) java: 找不到符号
  符号:   变量 emailKEY
  位置: 类 net.wendal.nutzbook.module.UserProfileModule

就是这样

12点吃饭之前还好好的呢。。。不知道为啥啊。

protected byte[] emailKEY = R.sg(24).next().getBytes();
添加回复
请先登陆
回到顶部