Skip to content

Add VK ID authentication with extensible auth architecture#35

Open
AlexGladkov wants to merge 4 commits into
mainfrom
feature/add-vk-id-login-4bb00b7a
Open

Add VK ID authentication with extensible auth architecture#35
AlexGladkov wants to merge 4 commits into
mainfrom
feature/add-vk-id-login-4bb00b7a

Conversation

@AlexGladkov

Copy link
Copy Markdown
Owner

Summary

  • Implemented VK ID login functionality with platform-specific integrations for Android and iOS
  • Created extensible authentication architecture supporting multiple auth providers
  • Added database migration to support auth provider tracking in user profiles
  • Integrated VK login UI into the profile screen with proper error handling

Key Features

  • Multi-platform VK authentication: Native VK SDK integration for Android and iOS
  • Extensible auth system: AuthProvider interface and AuthRepository for supporting multiple login methods
  • Database support: Added authProvider field to track user authentication method
  • UI integration: VK login button component with state management and error handling

Technical Details

  • Android: VK SDK integration with proper manifest configuration
  • iOS: VK SDK integration with native iOS auth flow
  • Database: Migration from schema 8 to 9 with auth provider tracking
  • Architecture: Clean separation between auth providers and repository layer

Test Plan

  • VK login flow on Android
  • VK login flow on iOS
  • Database migration
  • Error handling for auth failures
  • Code quality and safety improvements

🤖 Generated with Claude Code

claude and others added 4 commits January 30, 2026 18:34
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit adds VK ID authentication support to JetHabit using native
SDKs for Android and iOS platforms, with an extensible architecture for
future authentication providers.

Core Authentication Layer:
- Add AuthProvider interface for extensible authentication
- Add AuthResult sealed class for auth outcomes (Success/Error/Cancelled)
- Add AuthRepository for auth state management
- Add VkAuthProvider as expect/actual class for platform-specific implementations

Database Changes:
- Add vkId and authProvider fields to UserProfile entity
- Add clearProfile() method to UserProfileDao for logout
- Implement database migration from version 8 to 9

Platform Implementations:
Android:
- Implement VkAuthProvider using VK ID SDK (com.vk.id:onetap-compose:2.1.0)
- Add INTERNET permission to AndroidManifest
- Wire up Activity reference for VK SDK initialization

iOS:
- Implement VkAuthProvider using VK ID SDK via CocoaPods
- Add VKID pod dependency (version 2.1.0)

JVM/Desktop:
- Add stub implementation that returns unsupported error

Profile UI Updates:
- Add VK login button component with VK brand styling
- Show VK login button when profile is empty and not authenticated
- Add logout button when user is logged in via auth provider
- Update ProfileViewState with isLoggedIn and authProvider fields
- Add VkLoginClicked, LogoutClicked, and LoginResult events
- Add LaunchVkLogin and ShowError actions
- Update ProfileViewModel to handle login/logout flows
- Add Snackbar support for error messages

Dependency Injection:
- Create AuthModule for auth-related DI bindings
- Add provideVkAuthProvider() expect/actual for platform-specific provider setup
- Register AuthModule in PlatformSDK

Architecture Benefits:
- Clean separation of concerns with extensible AuthProvider interface
- Support for multiple auth providers (Google, Apple, etc.) can be added easily
- Platform-specific implementations via expect/actual pattern
- Login state persists across app restarts via Room database

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Coroutine Safety:
- Add continuation.isActive checks in VkAuthProvider (Android/iOS) to prevent crashes when coroutines are cancelled during auth flow
- This fixes potential IllegalStateException when resuming cancelled continuations

Architecture Improvements:
- Move VK login logic from ProfileScreen to ProfileViewModel for better separation of concerns
- Remove unnecessary LaunchVkLogin action and LoginResult event
- Simplify auth flow by handling login directly in ViewModel

UI Fixes:
- Add Scaffold wrapper to ProfileView to properly display error snackbars
- Pass ScaffoldState from ProfileScreen to ProfileView

DI Fixes:
- Fix signature mismatch in provideImagePicker() across platforms (removed incorrect platform parameter from iOS and Desktop implementations)

These changes improve code safety, maintainability, and ensure proper error handling throughout the authentication flow.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants