flutter_freedome_authentication

FreeDome authentication library for Flutter applications.

Features

  • User authentication (login/logout)
  • User registration
  • Password management (change/reset)
  • Token management (access/refresh tokens)
  • Secure password hashing
  • Persistent authentication state

Installation

Add this to your package's pubspec.yaml file:

dependencies:
  flutter_freedome_authentication: ^1.0.0

Usage

Authentication Service

import 'package:flutter_freedome_authentication/flutter_freedome_authentication.dart';

final authService = FreeDomeAuthService(baseUrl: 'https://api.example.com');

// Login
final result = await authService.login(
  username: 'user@example.com',
  password: 'password123',
);

if (result.success) {
  print('Logged in as: ${result.user?.displayName}');
}

// Logout
await authService.logout();

Registration Service

final registrationService = FreeDomeRegistrationService(baseUrl: 'https://api.example.com');

// Register new user
final result = await registrationService.register(
  RegistrationRequest(
    username: 'newuser',
    email: 'user@example.com',
    password: 'password123',
    firstName: 'John',
    lastName: 'Doe',
    metadata: {},
  ),
);

Password Service

final passwordService = FreeDomePasswordService(baseUrl: 'https://api.example.com');

// Change password
await passwordService.changePassword(
  currentPassword: 'oldpassword',
  newPassword: 'newpassword',
  accessToken: 'your_access_token',
);

// Request password reset
await passwordService.requestPasswordReset('user@example.com');

API Reference

Models

  • FreeDomeUser - User model with profile information
  • AuthResult - Authentication result with success/error status
  • RegistrationRequest - User registration data
  • PasswordChangeRequest - Password change data
  • PasswordResetRequest - Password reset data

Services

  • FreeDomeAuthService - Main authentication service
  • FreeDomeRegistrationService - User registration service
  • FreeDomePasswordService - Password management service

Events

  • UserLoggedInEvent - Fired when user logs in
  • UserLoggedOutEvent - Fired when user logs out
  • UserRegisteredEvent - Fired when user registers
  • PasswordChangedEvent - Fired when password is changed

License

MIT License - see LICENSE file for details.