Skip to content

daoseng33/Login

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

flowchart TD
    AuthViewModel -->|calls| AuthService
    AuthService -->|uses| KeychainService
    AuthService -->|uses| LocalAuthentication
    AuthViewModel -.->|publishes| UIStates
Loading

Login

A Swift-based authentication module for iOS that provides secure user login using password and biometric authentication (Face ID), with credential storage managed by the Keychain.

Features

  • User Registration & Login:
    Supports first-time user registration and returning user login with password validation.
  • Biometric Authentication:
    Integrates with iOS LocalAuthentication framework for Face ID login.
  • Keychain Integration:
    Stores and manages user credentials securely in the device Keychain.
  • MVVM Architecture:
    Uses a ViewModel for state management and logic separation.
  • Logout Support:
    Provides logout functionality and user session management.
  • Test Coverage:
    Includes integration and unit tests for authentication and keychain services.
截圖 2025-08-01 下午3 49 56

Structure

  • Login/Service/
    • AuthService.swift – Business logic for authentication and credential management.
    • KeychainService.swift – Handles secure storage and retrieval of credentials.
  • Login/Protocol/
    • AuthServiceProtocol.swift & KeychainServiceProtocol.swift – Protocol definitions for services.
  • Login/ViewModel/
    • AuthViewModel.swift – Observable object for handling UI state and validation.
  • LoginTests/ & LoginUITests/
    • Test cases for services and UI flows.

Key Classes

  • AuthService:
    Validates credentials, manages user registration, supports biometric authentication, and handles logout.
  • KeychainService:
    Provides save, update, retrieve, and delete operations for credential data in the Keychain.
  • AuthViewModel:
    Publishes authentication state and error messages, manages form validation and biometric support.

Biometric Authentication

To check if biometric authentication is available and trigger it:

if viewModel.isBiometricsAvailable {
    let result = try? authService.authenticateWithBiometrics()
    // Handle result: true (authenticated), false (failed)
}

Running Tests

This project includes unit and integration tests for all major components.
Run tests using Xcode's test navigator or with the following command:

xcodebuild test -scheme Login

Requirements

  • iOS 18.5+
  • Swift 5.6+
  • Xcode 16+

License

MIT


Created by DAO, 2025

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published