nban22 / Newspaper

Newspaper Web App: A dynamic online news platform with roles for guests, subscribers, writers, editors, and admins. Features include full-text search, category/tag filters, premium article access, WYSIWYG editor, and secure authentication using Express.js, TypeScript, MongoDB, and EJS
0 stars 0 forks source link

[Subscriber Features] Premium Article Access #14

Open nban22 opened 1 week ago

nban22 commented 1 week ago

Objective

Restrict access to premium articles for non-subscribers and allow subscribers to download PDF versions of premium articles.


Requirements

  1. Restrict Access for Non-Subscribers

    • Non-subscribers should be prevented from viewing the full content of premium articles.
    • Instead of displaying the full article, non-subscribers should be shown a message or a preview of the content, along with a prompt to subscribe to gain full access. This can be implemented as a content teaser or summary.
    • Example: "This is a premium article. Subscribe to view the full content."
  2. Subscription Check for Premium Articles

    • Before displaying the content of a premium article, check if the user is a subscriber. If the user is not a subscriber, redirect them to a subscription page or show the message mentioned above.
    • Use session data, cookies, or JWT tokens to check whether the user is logged in and if they have an active subscription. If they do not have a valid subscription, restrict access.
    • Example: If the user is not a subscriber, the server should return a restricted access response, or simply redirect them to the subscription page.
  3. Allow PDF Downloads for Subscribers

    • Subscribers should be able to download premium articles in PDF format.
    • Implement a download button or link in the article detail page that allows subscribers to download the article as a PDF file.
    • Ensure that the PDF includes the full content of the article, including the title, content, tags, and any other relevant information (e.g., images).
    • Use a library like pdfkit or puppeteer to generate the PDF from the article content.
  4. PDF Generation

    • Implement a backend route to generate the PDF for premium articles when requested.
    • For each premium article, ensure the backend can convert the article's HTML content into a downloadable PDF.
    • Example: When a user clicks on the "Download PDF" button, the backend will dynamically generate the PDF and serve it to the user.
  5. Access Control for PDF Download

    • Ensure that only subscribers can request the PDF download. If a non-subscriber tries to access the PDF, redirect them to the subscription page or show a message prompting them to subscribe.
    • Example: If a non-subscriber clicks the download button, the system should display a message like: "Please subscribe to download this article in PDF format."

Deliverables


Acceptance Criteria