Add VK ID authentication with extensible auth architecture#35
Open
AlexGladkov wants to merge 4 commits into
Open
Add VK ID authentication with extensible auth architecture#35AlexGladkov wants to merge 4 commits into
AlexGladkov wants to merge 4 commits into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Key Features
AuthProviderinterface andAuthRepositoryfor supporting multiple login methodsauthProviderfield to track user authentication methodTechnical Details
Test Plan
🤖 Generated with Claude Code