A shared folder with AI prompts and code snippets
From workspace: a0.dev
Team: Main
Total snippets: 4
4 snippets
Ensure only authorized users with specific roles can access certain routes or components.
I want to protect this route based on user roles: [Paste route/component info] Only allow access if the user has a specific role (e.g., 'admin'). Redirect unauthorized users.
Integrate Google login button and handle the OAuth flow securely.
Integrate Google OAuth login using a provider like Firebase, NextAuth, or Auth0. Show the full setup including client ID config and how to handle tokens after login.
Create an authentication form with email and password input fields and validate them properly.
Build a login form that accepts email and password. On submit, validate input and send credentials to the backend. Provide complete form component and basic validation logic.
Keep the user logged in by storing the session token securely and restoring it on page reload.
Make sure user stays logged in after a page reload. Persist token or session in a secure way (e.g. HTTP-only cookie or localStorage) Restore session on app load.