use of com.jeanchampemont.wtfdyum.security.Secured in project WTFDYUM by jchampemont.
the class AdminController method index.
@RequestMapping(method = RequestMethod.GET)
@Secured
public ModelAndView index() {
if (!authenticationService.isAdmin()) {
return new ModelAndView("redirect:/");
}
ModelAndView result = new ModelAndView("admin/index");
final Long userId = authenticationService.getCurrentUserId();
try {
result.getModel().put("user", twitterService.getUser(SessionManager.getPrincipal(), userId));
} catch (final WTFDYUMException e) {
authenticationService.logOut();
return new ModelAndView("redirect:/");
}
result.getModel().put("membersCount", principalService.countMembers());
Map<String, Integer> featureEnabledCount = adminService.countEnabledFeature(principalService.getMembers()).entrySet().stream().collect(toMap(e -> e.getKey().name(), Map.Entry::getValue));
result.getModel().put("availableFeatures", Feature.values());
result.getModel().put("featureEnabledCount", featureEnabledCount);
return result;
}
use of com.jeanchampemont.wtfdyum.security.Secured in project WTFDYUM by jchampemont.
the class UserController method index.
@RequestMapping(method = RequestMethod.GET)
@Secured
public ModelAndView index() {
final ModelAndView result = new ModelAndView("user/index");
final Long userId = authenticationService.getCurrentUserId();
try {
result.getModel().put("user", twitterService.getUser(SessionManager.getPrincipal(), userId));
} catch (final WTFDYUMException e) {
authenticationService.logOut();
return new ModelAndView("redirect:/");
}
result.getModel().put("events", userService.getRecentEvents(userId, 10));
result.getModel().put("availableFeatures", Feature.values());
final Map<String, Boolean> featuresStatus = new HashMap<>();
for (final Feature f : Feature.values()) {
featuresStatus.put(f.name(), featureService.isEnabled(userId, f));
}
result.getModel().put("featuresStatus", featuresStatus);
return result;
}
Aggregations