bloomBUILD•SHIP•BLOOM
.md
Auth System

Authentication & Sessions

Manage user sessions, tokens, and role-based permissions with reactive signals connected to filesystem routing guards.

BloomAuthBase Interface

lib/features/auth/auth_service.dart
dart
// lib/features/auth/auth_service.dart
import 'package:bloom_framework/bloom.dart';

class UserProfile {
  final String id;
  final String email;
  UserProfile({required this.id, required this.email});
}

class AuthService extends BloomAuthBase<UserProfile> {
  Future<void> login(String email, String password) async {
    // Perform remote API call
    final user = UserProfile(id: '123', email: email);
    // Sets reactive signals: isAuthenticated.value = true, user.value = user
    setUser(user);
  }

  Future<void> logout() async {
    setUser(null); // Triggers route guard redirection automatically
  }
}