Search in sources :

Example 1 with TbUser

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);
}
Also used : TbUser(cn.exrick.manager.pojo.TbUser) ApiOperation(io.swagger.annotations.ApiOperation)

Example 2 with 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;
    }
}
Also used : SimpleAuthenticationInfo(org.apache.shiro.authc.SimpleAuthenticationInfo) TbUser(cn.exrick.manager.pojo.TbUser) AuthenticationInfo(org.apache.shiro.authc.AuthenticationInfo) SimpleAuthenticationInfo(org.apache.shiro.authc.SimpleAuthenticationInfo)

Aggregations

TbUser (cn.exrick.manager.pojo.TbUser)2 ApiOperation (io.swagger.annotations.ApiOperation)1 AuthenticationInfo (org.apache.shiro.authc.AuthenticationInfo)1 SimpleAuthenticationInfo (org.apache.shiro.authc.SimpleAuthenticationInfo)1