Commit 46773f31 by zhanghj

V1.0.0--提交session中用户id的获取

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@17312 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent 4338339a
......@@ -340,7 +340,13 @@ public class UserController extends BaseController {
//String pwd = sysUserService.encryptPassword(username, password);
UsernamePasswordToken token = new UsernamePasswordToken(username, password);
subject.login(token);
List<SysUser> list = sysUserService.findByUserName(username);
SysUser sysUser = null;
if (list != null && !list.isEmpty()) {
sysUser = list.get(0);
}
session.setAttribute(com.glsx.common.constants.Constants.SESSION_USERNAME_KEY, username);
session.setAttribute(com.glsx.common.constants.Constants.SESSION_USERID_KEY, sysUser.getUserId());
map.put("JSESSIONID", subject.getSession().getId());
result.setData(map);
} catch (UnknownAccountException uae) {
......@@ -391,14 +397,17 @@ public class UserController extends BaseController {
boolean isLogin = subject.isAuthenticated();
SysUser user = null;
String username = null;
Integer userId = null;
if (isLogin) {
user = (SysUser) subject.getPrincipal();
if (user != null) {
username = user.getUsername();
userId = user.getId();
}
}
map.put("isLogin", isLogin);
map.put(com.glsx.common.constants.Constants.SESSION_USERNAME_KEY, username);
map.put(com.glsx.common.constants.Constants.SESSION_USERID_KEY, userId);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), map);
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!