NutzCN Logo
问答 nutz.cn源码里面 @Attr(value="me", scope=Scope.SESSION)Integer uid 的“me”在哪里设置的?
发布于 3102天前 作者 chineselio 2217 次浏览 复制 上一个帖子 下一个帖子
标签: nutzcn shiro

源码中没找到。。。。

1 回复

你找 NutShiro.SessionKey 的引用就是的, NutShiro.SessionKey的默认值就是"me"

例如CaptchaFormAuthenticationFilter类

protected boolean onLoginSuccess(AuthenticationToken token, Subject subject, ServletRequest req, ServletResponse resp) throws Exception {
        subject.getSession().setAttribute(NutShiro.SessionKey, subject.getPrincipal());
        if (NutShiro.isAjax(req)) {
            NutShiro.rendAjaxResp(req, resp, new NutMap().setv("ok", true));
            return false;
        }
        return super.onLoginSuccess(token, subject, req, resp);
    }

例如OauthModule

	// 进行Shiro登录
	protected void doShiroLogin(int userId, String _providerId) {
		Subject subject = SecurityUtils.getSubject();
		subject.login(new OAuthAuthenticationToken(userId));
		subject.getSession().setAttribute(NutShiro.SessionKey, userId);
		sysLogService.async(SysLog.c("method", "用户登陆", null, userId, "用户通过"+_providerId+" Oauth登陆"));
	}
添加回复
请先登陆
回到顶部