W
Wasp•5d ago
ComputO

Is there a way to put integrate blog and docs with the login authentication?

I was working on a closed source platform for which the documentation is supposed to be private. The astro based documentation and blog are effect but how can I integrate them directly in app so that one can access them only after logging in.
9 Replies
kapa.ai
kapa.ai•5d ago
Hi @ComputO. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the knowledge sources provided, there isn't specific information about integrating a blog and documentation system directly with Wasp's authentication. However, I can provide some general guidance on how you might approach this using Wasp's authentication features: 1. Page Protection: Wasp allows you to protect pages by setting the authRequired property to true. As mentioned in the Auth Overview documentation, you can use this to ensure only authenticated users can access certain pages:
page DocsPage {
component: import Docs from "@src/pages/Docs",
authRequired: true
}

page BlogPage {
component: import Blog from "@src/pages/Blog",
authRequired: true
}
page DocsPage {
component: import Docs from "@src/pages/Docs",
authRequired: true
}

page BlogPage {
component: import Blog from "@src/pages/Blog",
authRequired: true
}
2. Redirect Unauthenticated Users: When you set up authentication in your Wasp app, you can specify where unauthenticated users should be redirected using the onAuthFailedRedirectTo field, as mentioned in the Auth API Reference. 3. Server-side Protection: For any API routes or operations that serve your documentation or blog content, you can use the context.user object to check if a user is authenticated and deny access if they're not. The Auth Overview documentation provides an example of how to do this:
import { HttpError } from 'wasp/server'

export const getDocContent = async (args, context) => {
if (!context.user) {
throw new HttpError(403)
}
// Fetch and return doc content
}
import { HttpError } from 'wasp/server'

export const getDocContent = async (args, context) => {
if (!context.user) {
throw new HttpError(403)
}
// Fetch and return doc content
}
To fully integrate your Astro-based documentation and blog with Wasp, you might need to: 1. Port your Astro content to React components that can be used within Wasp. 2. Set up the appropriate pages and routes in your Wasp app. 3. Implement the necessary queries or actions to fetch and display your content. 4. Ensure all these are protected using the authentication methods described above. However, it's important to note that the provided knowledge sources don't contain specific information about integrating external documentation systems or blogs with Wasp. You might need to consult additional resources or the Wasp community for more detailed guidance on this specific use case. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @ComputO, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
Filip
Filip•22h ago
Hey @ComputO. Still need help with this?
ComputO
ComputOOP•22h ago
Yes ... I was able to deploy the blog and docs but could not integrate it with login
MEE6
MEE6•22h ago
Wohooo @ComputO, you just became a Waspeteer level 1!
Filip
Filip•21h ago
In that case, I think I'll leave this to @Vinny (@Wasp), the creator of Open saas.\
Vinny (@Wasp)
Vinny (@Wasp)•21h ago
This won't be possible unless you build a blog within the Wasp app itself, or you'd have to integrate a separate auth system for the blog only. For implementing a blog within the Wasp app, the answer Kapa gave above is a good start. I know that @NEROX also has implemented his own blog within his Wasp/Open SaaS app. Maybe he has some extra tips 🙂
ComputO
ComputOOP•20h ago
Building components again in wasp app seems a bit of a stretch.. if you know anyone who has directly integrated astro in wasp app that would help a lot.. or else currently we were thinking of adding auth to astro with same users & auth tables that we have through wasp
NEROX
NEROX•20h ago
GitHub
GitHub - NeroxTGC/WaspTemplate: Simple Blog made with Wasp
Simple Blog made with Wasp. Contribute to NeroxTGC/WaspTemplate development by creating an account on GitHub.
ComputO
ComputOOP•16h ago
first of all cool repo .. and cool demos .. but all my docs are already in Md .. so was searching for a direct lift and shift

Did you find this page helpful?