Skip to content

flutter-news-app-full-source-code/auth-repository

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flutter News App Toolkit Logo

Auth Repository

A repository that provides an abstraction layer over authentication operations for the Flutter News App Toolkit.

coverage Live Docs: View Main Project: Browse

This auth_repository package contains the AuthRepository class, which acts as an abstraction layer over an AuthClient implementation (from the auth_client package) within the Flutter News App Full Source Code Toolkit. Its primary purpose is to provide a clean, business-focused interface for authentication flows, ensuring standardized exception propagation, and handling authentication token persistence using KvStorageService. This repository effectively decouples the application's core logic from the specifics of authentication mechanisms and token storage.

⭐ Feature Showcase: Business-Focused Authentication Management

This package offers a comprehensive set of features for managing authentication operations.

🧱 Core Functionality

🚀 AuthRepository Class

  • AuthRepository: Provides a clean, business-focused interface for authentication-related tasks, abstracting the underlying AuthClient implementation.
  • Complete Authentication Lifecycle: Offers methods for a full authentication lifecycle, including authStateChanges (stream of user authentication state), getCurrentUser (retrieves current user), requestSignInCode (initiates email+code sign-in), verifySignInCode (verifies code, saves token, returns user), signInAnonymously (signs in anonymously, saves token, returns user), and signOut (signs out user, clears token).

🌐 Token Persistence Management

  • KvStorageService Integration: Manages authentication token persistence internally using an injected KvStorageService.
  • Direct Token Access: Exposes saveAuthToken(String token), getAuthToken(), and clearAuthToken() for direct token manipulation, though these are typically handled by the main authentication flow methods.

🛡️ Standardized Error Handling

  • Exception Propagation: Propagates standardized HttpExceptions (from core) from the underlying client and StorageExceptions (from kv_storage_service), ensuring consistent and predictable error management across the application layers.

💉 Dependency Injection Ready

  • AuthClient & KvStorageService Dependencies: Requires instances of AuthClient (from auth_client) and KvStorageService (from kv_storage_service) via its constructor, promoting loose coupling and testability.

💡 Your Advantage: This package provides a business-focused abstraction for authentication operations, simplifying the integration of user authentication into your application logic. It ensures consistent error handling, manages token persistence, and decouples your core application from specific authentication and storage implementations, enhancing maintainability and flexibility.

🔑 Licensing

This auth_repository package is an integral part of the Flutter News App Full Source Code Toolkit. For comprehensive details regarding licensing, including trial and commercial options for the entire toolkit, please refer to the main toolkit organization page.

About

A repository that provides an abstraction layer over authentication operations for the Flutter News App Toolkit.

Resources

Stars

Watchers

Forks

Languages