forked from Archives/Athou_commafeed
disable import for the demo user
This commit is contained in:
@@ -7,6 +7,7 @@ import org.apache.wicket.RestartResponseException;
|
||||
import org.apache.wicket.markup.html.WebPage;
|
||||
import org.apache.wicket.request.mapper.parameter.PageParameters;
|
||||
|
||||
import com.commafeed.backend.StartupBean;
|
||||
import com.commafeed.backend.dao.UserDAO;
|
||||
import com.commafeed.backend.feeds.OPMLImporter;
|
||||
import com.commafeed.backend.model.ApplicationSettings;
|
||||
@@ -95,6 +96,10 @@ public class GoogleImportCallbackPage extends WebPage {
|
||||
String opml = httpRequest.execute().parseAsString();
|
||||
User user = CommaFeedSession.get().getUser();
|
||||
if (user != null) {
|
||||
if (StartupBean.USERNAME_DEMO.equals(user.getName())) {
|
||||
throw new DisplayException(
|
||||
"Import is disabled for the demo account");
|
||||
}
|
||||
importer.importOpml(CommaFeedSession.get().getUser(), opml);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.commafeed.backend.StartupBean;
|
||||
import com.commafeed.backend.feeds.FetchedFeed;
|
||||
import com.commafeed.backend.model.FeedCategory;
|
||||
import com.commafeed.backend.model.FeedEntryStatus;
|
||||
@@ -326,6 +327,10 @@ public class FeedREST extends AbstractResourceREST {
|
||||
@Consumes(MediaType.MULTIPART_FORM_DATA)
|
||||
@ApiOperation(value = "OPML import", notes = "Import an OPML file, posted as a FORM with the 'file' name")
|
||||
public Response importOpml() {
|
||||
if (StartupBean.USERNAME_DEMO.equals(getUser().getName())) {
|
||||
return Response.status(Status.UNAUTHORIZED)
|
||||
.entity("Import is disabled for the demo account").build();
|
||||
}
|
||||
try {
|
||||
FileItemFactory factory = new DiskFileItemFactory(1000000, null);
|
||||
ServletFileUpload upload = new ServletFileUpload(factory);
|
||||
|
||||
Reference in New Issue
Block a user