use of cn.exrick.manager.pojo.TbUser in project xmall by Exrick.
the class UserController method getUserInfo.
@RequestMapping(value = "/user/userInfo", method = RequestMethod.GET)
@ApiOperation(value = "获取登录用户信息")
public Result<TbUser> getUserInfo() {
String username = SecurityUtils.getSubject().getPrincipal().toString();
TbUser tbUser = userService.getUserByUsername(username);
tbUser.setPassword(null);
return new ResultUtil<TbUser>().setData(tbUser);
}
use of cn.exrick.manager.pojo.TbUser in project xmall by Exrick.
the class MyRealm method doGetAuthenticationInfo.
/**
* 先执行登录验证
* @param token
* @return
* @throws AuthenticationException
*/
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
// 获取用户名密码
String username = token.getPrincipal().toString();
TbUser tbUser = userService.getUserByUsername(username);
if (tbUser != null) {
// 得到用户账号和密码存放到authenticationInfo中用于Controller层的权限判断 第三个参数随意不能为null
AuthenticationInfo authenticationInfo = new SimpleAuthenticationInfo(tbUser.getUsername(), tbUser.getPassword(), tbUser.getUsername());
return authenticationInfo;
} else {
return null;
}
}
Aggregations