use of com.ganster.cms.core.pojo.User in project Ganster-CMS by Gangster-trio.
the class PrivilegeController method judgeSite.
@GetMapping("/site")
public Message judgeSite(@RequestParam Integer siteId) {
Integer userId = (Integer) SecurityUtils.getSubject().getSession().getAttribute("id");
User user = userService.selectByPrimaryKey(userId);
if (!"admin".equals(user.getUserName())) {
if (PermissionUtil.permittedSite(userId, siteId)) {
return super.buildMessage(0, "success", "yes");
} else {
return super.buildMessage(2, "no privilege", null);
}
} else {
return super.buildMessage(0, "success", "yes");
}
}
use of com.ganster.cms.core.pojo.User in project Ganster-CMS by Gangster-trio.
the class SystemSettingController method list.
// id代表站点id
@GetMapping("/list/{id}")
public List<SettingEntry> list(@PathVariable Integer id) {
Integer userId = (Integer) SecurityUtils.getSubject().getSession().getAttribute("id");
User user = userService.selectByPrimaryKey(userId);
if (userId == null) {
return null;
} else {
SettingEntryExample settingEntryExample = new SettingEntryExample();
if (!user.getUserName().equals("admin")) {
if (PermissionUtil.permittedModule(userId, id, 9, CmsConst.PERMISSION_READ)) {
return settingService.selectByExample(settingEntryExample);
} else {
return null;
}
}
return settingService.selectByExample(settingEntryExample);
}
}
use of com.ganster.cms.core.pojo.User in project Ganster-CMS by Gangster-trio.
the class InformationController method findInformation.
@GetMapping("/{UserId}")
public Message findInformation(@PathVariable("UserId") Integer userId) {
Message message = new Message();
InformationObject informationObject = new InformationObject();
User user = userService.selectByPrimaryKey(userId);
informationObject.setUserName(user.getUserName());
informationObject.setUserPhone(user.getUserPhone());
informationObject.setUserEmail(user.getUserEmail());
informationObject.setUserStatus(user.getUserStatus());
informationObject.setUserCreateTime(user.getUserCreateTime());
informationObject.setUserOrg(user.getUserOrg());
List<String> groupName = groupService.selectByUserId(userId).stream().map(group -> "<input type='text' disabled='disabled' value='" + group.getGroupName() + "'" + "class='layui-input'" + "/>").collect(Collectors.toList());
informationObject.setUserGroup(groupName);
message.setData(informationObject);
return message;
}
use of com.ganster.cms.core.pojo.User in project Ganster-CMS by Gangster-trio.
the class UserShiroRealm method doGetAuthenticationInfo.
/**
* 认证信息.(身份验证)
* Authentication 是用来验证用户身份
*/
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
String username = (String) token.getPrincipal();
String password = new String((char[]) token.getCredentials());
logger.debug("用户登录:{} 凭证:{}", username, password);
UserExample userExample = new UserExample();
userExample.createCriteria().andUserNameEqualTo(username);
List<User> users = userService.selectByExample(userExample);
if (users.isEmpty()) {
throw new UnknownAccountException();
}
User user = users.get(0);
if (!user.getUserPassword().equals(password)) {
throw new IncorrectCredentialsException();
}
// 此方法废弃
SecurityUtils.getSubject().getSession().setAttribute("id", user.getUserId());
return new SimpleAuthenticationInfo(user, password, getName());
}
Aggregations