java - Cannot get principal in SecurityUtils.getSubject() -
using shiro, when login
@requestmapping(value = "/login", method = requestmethod.post) @responsebody public responseentity<restresult> login(@valid @requestbody user user, bindingresult result, httpsession session, httpservletrequest request) { subject subject = securityutils.getsubject(); result result = userservice.login(user.getname(), user.getpassword()); if (result.issuccess()) { usernamepasswordtoken token = new usernamepasswordtoken(user.getname(), user.getpassword(), false, request.getremotehost()); subject.login(token); } return result.toresponseentity(); }
and in logout method:
@requestmapping("/logout") @responsebody public responseentity<restresult> logout(httpsession session) { subject subject = securityutils.getsubject(); subject.logout(); return result.success().build(); }
the snippet seems ok,but in logout method, members in subject below,
as picture indicates principal null, so, what's matter?
Comments
Post a Comment