Files
retail/docs/QUICK_AUTH_GUIDE.md
2025-10-10 21:49:17 +07:00

1.8 KiB
Raw Permalink Blame History

🚀 Quick Authentication Guide

1 Start Backend

cd your-backend
npm run start:dev

2 Run App

flutter run

3 Login

// In your widget
final success = await ref.read(authProvider.notifier).login(
  email: 'user@example.com',
  password: 'Password123!',
);

4 Check Auth Status

final isAuth = ref.watch(isAuthenticatedProvider);
final user = ref.watch(currentUserProvider);

5 Use API (Auto-Authenticated!)

// Token automatically included in headers
final products = await getProducts();
final categories = await getCategories();

6 Logout

await ref.read(authProvider.notifier).logout();

🔑 Key Endpoints

Endpoint Auth Required Description
POST /api/auth/login No Login user
POST /api/auth/register No Register user
GET /api/auth/profile Yes Get profile
GET /api/products No Get products
GET /api/categories No Get categories

📍 Important Files

  • Login Page: lib/features/auth/presentation/pages/login_page.dart
  • Auth Provider: lib/features/auth/presentation/providers/auth_provider.dart
  • API Config: lib/core/constants/api_constants.dart
  • Full Docs: AUTH_READY.md

Bearer Token Flow

Login → Token Saved → Token Set in Dio → All API Calls Auto-Authenticated

You never need to manually add tokens! 🎉


🎯 Test Credentials

Create in your backend:

{
  "email": "test@retailpos.com",
  "password": "Test123!",
  "name": "Test User"
}

Status

  • Errors: 0
  • Build: SUCCESS
  • Auth: READY
  • Documentation: COMPLETE

Just run flutter run and start using! 🚀