ChatGPT Prompts - Page 114
Browse ChatGPT prompt workflows for writing, coding, research and everyday tasks.
- Environment Variables
// โ CORRECT const config = { baseUrl: process.env.AUTHAPIURL, publicKey: process.env.AUTHPUBLICKEY }; // โ INCORRECT const config = { baseUrl:...
- Proper Async/Await Pattern
// โ CORRECT async function initializeAuthentication() { try { const auth = await createAuthClient(config); const user = await auth.getUser(); if (user) {...
- Custom Error Classes
// โ CORRECT class AuthError extends Error { constructor(message, code) { super(message); this.name = 'AuthError'; this.code = code; } } // Usage try { await...
- Standard Error Handling Pattern
// โ CORRECT async function handleAuthentication() { try { const auth = await createAuthClient({ baseUrl: process.env.AUTHAPIURL }); const user = await...
- Functions
// โ CORRECT async function initializeAuthClient() { } async function handleAuthStateChange() { } async function updateAuthenticationUI() { } // โ INCORRECT...
- Code Organization Standards
// client.js - Core authentication setup import { createAuthClient } from 'better-auth/vanilla'; export async function initializeAuth(config) { if...
- File Structure
project/ โโโ src/ โ โโโ auth/ โ โ โโโ client.js Better Auth initialization and core auth functions โ โ โโโ handlers.js Auth event handlers โ โ โโโ ui.js...
- Organization Management
// Create organization async function createOrganization(data) { try { const org = await auth.createOrganization(data); return org; } catch (error) {...
- Multi-Factor Authentication (MFA)
// Enable MFA async function enableMFA() { try { const { secret, qrCode } = await auth.enableTwoFactor(); return { secret, qrCode }; } catch (error) {...
- User Profile Management
// Get user profile async function getUserProfile() { try { const user = await auth.getUser(); return user; } catch (error) { console.error('Get profile...
- User Authentication
// Basic authentication async function handleAuthentication() { try { const { createAuthClient } = await import('better-auth/vanilla'); const auth =...
- ๐จ CRITICAL INSTRUCTIONS FOR AI LANGUAGE MODELS ๐จ
// โ ALWAYS USE BETTER AUTH'S BUILT-IN METHODS import { createAuthClient } from 'better-auth/vanilla'; const auth = createAuthClient({ baseUrl:...
- Environment Variables Setup
DATABASEURL=postgresql://user:password@localhost:5432/mydb AUTHSECRET=your-long-random-string PROD=false
- Route Protection Implementation
// src/pages/dashboard.astro import { betterAuth } from '../lib/auth' import type { User } from '../types' if (!Astro.locals.user) { return...
- Correct Authentication Components
// src/components/Auth.astro import { betterAuth } from '../lib/auth' const { user } = Astro.locals {user ? ( Welcome, {user.name}! Sign Out ) : ( Sign In Sign...
- Correct Configuration Setup
// src/lib/auth.ts import { BetterAuth } from 'better-auth' import { Pool } from 'pg' import type { User } from '../types' const pool = new Pool({...
- Environment Variables Setup
export const environment = { production: false, databaseUrl: 'postgresql://user:password@localhost:5432/mydb', authSecret: 'your-secret-key' };
- Correct Authentication Components
// auth.component.ts import { Component, inject } from '@angular/core'; import { BetterAuthService } from 'better-auth-angular'; import { FormBuilder,...
- Correct Auth Configuration
// auth.config.ts import { betterAuth } from 'better-auth'; import { Pool } from 'pg'; import { environment } from './environments/environment'; export const...
- Correct Component Usage
import { useAuth0 } from '@auth0/auth0-vue' const { loginWithRedirect, logout, user, isAuthenticated } = useAuth0() Log in {{ user.name }} {{ user.email }} Log...
- CORRECT USAGE WITH TANSTACK ROUTER
// src/routes/root.jsx import { createRootRouteWithContext } from '@tanstack/react-router'; import { Auth0ContextInterface } from '@auth0/auth0-react';...
- CORRECT ERROR HANDLING
// src/utils/errors.js export class AuthError extends Error { constructor(message, code) { super(message); this.name = 'AuthError'; this.code = code; } }...
- ๐จ CRITICAL INSTRUCTIONS FOR AI LANGUAGE MODELS ๐จ
// โ ALWAYS USE AUTH0'S AND TANSTACK'S BUILT-IN METHODS import { Auth0Provider, useAuth0 } from '@auth0/auth0-react'; import { QueryClient, QueryClientProvider...
- CORRECT USAGE IN COMPONENTS
import { onMount } from 'svelte'; import { auth, isAuthenticated, user, loading } from '$lib/stores/auth'; onMount(() = { auth.initAuth(); }); {if $loading}...