use of org.libresonic.player.domain.User in project libresonic by Libresonic.
the class LoginController method login.
@RequestMapping(value = "/login", method = RequestMethod.GET)
public ModelAndView login(HttpServletRequest request, HttpServletResponse response) throws Exception {
// Auto-login if "user" and "password" parameters are given.
String username = request.getParameter("user");
String password = request.getParameter("password");
if (username != null && password != null) {
username = StringUtil.urlEncode(username);
password = StringUtil.urlEncode(password);
return new ModelAndView(new RedirectView("/login?" + UsernamePasswordAuthenticationFilter.SPRING_SECURITY_FORM_USERNAME_KEY + "=" + username + "&" + UsernamePasswordAuthenticationFilter.SPRING_SECURITY_FORM_PASSWORD_KEY + "=" + password));
}
Map<String, Object> map = new HashMap<String, Object>();
map.put("logout", request.getParameter("logout") != null);
map.put("error", request.getParameter("error") != null);
map.put("brand", settingsService.getBrand());
map.put("loginMessage", settingsService.getLoginMessage());
User admin = securityService.getUserByName(User.USERNAME_ADMIN);
if (User.USERNAME_ADMIN.equals(admin.getPassword())) {
map.put("insecure", true);
}
return new ModelAndView("login", "model", map);
}
use of org.libresonic.player.domain.User in project libresonic by Libresonic.
the class PlayQueueController method handleRequestInternal.
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
User user = securityService.getCurrentUser(request);
UserSettings userSettings = settingsService.getUserSettings(user.getUsername());
Player player = playerService.getPlayer(request, response);
Map<String, Object> map = new HashMap<>();
map.put("user", user);
map.put("player", player);
map.put("players", playerService.getPlayersForUserAndClientId(user.getUsername(), null));
map.put("visibility", userSettings.getPlaylistVisibility());
map.put("partyMode", userSettings.isPartyModeEnabled());
map.put("notify", userSettings.isSongNotificationEnabled());
map.put("autoHide", userSettings.isAutoHidePlayQueue());
return new ModelAndView("playQueue", "model", map);
}
use of org.libresonic.player.domain.User in project libresonic by Libresonic.
the class PlaylistsController method doGet.
@RequestMapping(method = RequestMethod.GET)
public String doGet(HttpServletRequest request, Model model) throws Exception {
Map<String, Object> map = new HashMap<>();
User user = securityService.getCurrentUser(request);
List<Playlist> playlists = playlistService.getReadablePlaylistsForUser(user.getUsername());
map.put("playlists", playlists);
model.addAttribute("model", map);
return "playlists";
}
use of org.libresonic.player.domain.User in project libresonic by Libresonic.
the class RESTController method getPlaylists.
@RequestMapping(value = "/rest/getPlaylists", method = { RequestMethod.GET, RequestMethod.POST })
public void getPlaylists(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
User user = securityService.getCurrentUser(request);
String authenticatedUsername = user.getUsername();
String requestedUsername = request.getParameter("username");
if (requestedUsername == null) {
requestedUsername = authenticatedUsername;
} else if (!user.isAdminRole()) {
error(request, response, ErrorCode.NOT_AUTHORIZED, authenticatedUsername + " is not authorized to get playlists for " + requestedUsername);
return;
}
Playlists result = new Playlists();
for (Playlist playlist : playlistService.getReadablePlaylistsForUser(requestedUsername)) {
result.getPlaylist().add(createJaxbPlaylist(new org.libresonic.restapi.Playlist(), playlist));
}
Response res = createResponse();
res.setPlaylists(result);
jaxbWriter.writeResponse(request, response, res);
}
use of org.libresonic.player.domain.User in project libresonic by Libresonic.
the class RESTController method createPodcastChannel.
@RequestMapping(value = "/rest/createPodcastChannel", method = { RequestMethod.GET, RequestMethod.POST })
public void createPodcastChannel(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
User user = securityService.getCurrentUser(request);
if (!user.isPodcastRole()) {
error(request, response, ErrorCode.NOT_AUTHORIZED, user.getUsername() + " is not authorized to administrate podcasts.");
return;
}
String url = getRequiredStringParameter(request, "url");
podcastService.createChannel(url);
writeEmptyResponse(request, response);
}
Aggregations