Skip to content

feat(auth,realtime): Google Authentication, Account Linking, and Real-time Live Synchronization - #171

Merged
Decuayer merged 5 commits into
mainfrom
feat/SDDC-90-google-auth-account-linking-realtime-sync
Sep 24, 2026
Merged

Decuayer merged 5 commits into
mainfrom
feat/SDDC-90-google-auth-account-linking-realtime-sync

Conversation

@Decuayer

@Decuayer Decuayer commented Sep 9, 2026

Copy link
Copy Markdown
Owner

🎯 Jira / Task Reference

  • Jira Issue: SDDC-90
  • Component: [backend | mobile | web | database]

📝 Summary of Changes

This pull request delivers Google Authentication & Account Linking across Mobile and Web, addresses duplicate notifications, and introduces full real-time synchronization so neither web operators nor mobile field users need to refresh pages:

1. Google Authentication & Account Linking

  • Backend:
    • Added GoogleId (indexed) and GoogleEmail to User entity with migration AddGoogleAccountLinkingToUser.
    • Added POST /api/v1/auth/google-register (GoogleRegisterCommand) for onboarding new employees via Google.
    • Enhanced POST /api/v1/auth/google-login (GoogleLoginCommand) to resolve and auto-link by Google ID or corporate email.
    • Implemented POST /api/v1/users/me/link-google & POST /api/v1/users/me/unlink-google for profile account linking.
  • Web Panel (Blazor WebAssembly):
    • Added "Connected Accounts (Google Entegrasyonu)" section in Profile Settings with live status badge, Google sign-in linking button, and unlink option.
    • Updated googleAuth.js with initLink to support OAuth linking directly from settings.
  • Mobile (Flutter):
    • Integrated google_sign_in: ^6.2.2 and created reusable GoogleAuthService.
    • Added Google Sign-In button on LoginView.
    • Added Google Sign-Up button on RegisterView.
    • Added GoogleAccountTile with link/unlink actions and confirmation dialog on ProfileView.

2. Real-Time Live Sync (Zero-Refresh)

  • Mobile:
    • Updated app.dart to initialize EmployeeTrackingHubService for both RoleType.employee and RoleType.team.
    • Added NewIncident, IncidentUpdated, IncidentStatusChanged, TeamDispatched, and TeamLocationUpdated reactive streams.
    • EmployeeHomeView now automatically refreshes list on RapidIncidentSuccess and live SignalR events.
    • TeamDashboardView now listens to onTeamDispatched and onIncidentStatusChanged, immediately switching to the active task, triggering a high-priority local push notification, and refreshing unit state without manual swipe-to-refresh.
  • Web Panel:
    • Centralized SignalR hub connection startup in MainLayout.razor across all pages (/incidents, /teams, /users, /settings).
    • Added live subscription handling in Incidents.razor.cs and Teams.razor.cs.

3. Notification Deduplication & Deep Linking

  • Eliminated duplicate SendAsync invocations in backend MediatR notification handlers (IncidentStatusChanged, IncidentUpdated, AssignmentCreated, TeamLocationUpdated).
  • Added a 3-second sliding window deduplication cache in Web ToastService.cs.
  • Enabled interactive emergency toast notifications with deep-linking: clicking an alert redirects to /map?incidentId={id}&lat={lat}&lng={lng} and focuses the map on the incident coordinates.

🏷️ Type of Change

  • 🚀 Feature: New functionality or operational workflow
  • 🐛 Bug Fix: Non-breaking fix for an identified defect (duplicate notifications & hub lifecycle)
  • ♻️ Refactor: Code restructuring without behavior alteration
  • ⚡ Performance: Real-time push updates eliminating manual polling
  • 🛠️ Chore / Infra: Dependencies, Docker, CI/CD, or tooling updates
  • 📖 Documentation: README, API specs, or code documentation updates
  • ⚠️ Breaking Change: Requires schema migration (AddGoogleAccountLinkingToUser)

🧪 Testing & Verification

Automated Tests

  • Backend unit & application tests executed: dotnet test (202 / 202 passed)
    • SocarDispatch.UnitTests: 16 passed
    • SocarDispatch.Application.Tests: 169 passed
    • SocarDispatch.Infrastructure.Tests: 17 passed
  • Web build passed: dotnet build clients/web/SocarDispatch.Web/SocarDispatch.Web.csproj (0 errors, 0 warnings)
  • Mobile tests executed: flutter test (86 / 86 passed)
  • Linter & formatting passed: flutter analyze (No issues found)

Manual Test Steps

  1. Web Google Linking: Navigate to Settings > Profile, connect Google account, log out, and log back in using Google Sign-In.
  2. Mobile Google Auth: Register new employee via Google on mobile, test Google login on LoginView, verify Google status tile in ProfileView.
  3. Live Sync (Zero-Refresh): With mobile app open on the Dashboard, create an incident or assign a team from the Web Panel; observe immediate real-time UI updates and high-priority push notification on the device without swiping to refresh.
  4. Interactive Deep-Linking: Click emergency toast on the Web Panel from any page; verify automatic redirection to /map with coordinate focus and pulse animation.

📋 Pre-Merge Checklist

  • My code adheres to the project's Clean Architecture & style guidelines.
  • I have self-reviewed my own code before requesting review.
  • Database migrations are backwards-compatible (GoogleId and GoogleEmail are nullable).
  • Sensitive secrets / tokens are NOT committed.
  • Jira status updated to In Review.

…time live sync

- Add GoogleId and GoogleEmail to User entity with unique constraint and EF Core migration
- Implement GoogleRegisterCommand, GoogleLoginCommand, LinkGoogleAccountCommand and UnlinkGoogleAccountCommand
- Add Google account linking and unlinking card in Web Panel profile settings
- Integrate google_sign_in package with GoogleAuthService in Mobile (Login, Register and Profile)
- Centralize SignalR hub connections across all authenticated Web pages and Mobile roles
- Remove duplicate SignalR notification invocations from backend handlers
- Add 3-second sliding window deduplication and interactive deep-linking to Web ToastService
- Auto-refresh incidents on mobile and dispatch local emergency notifications on team dispatch without manual refresh
Closes #SDDC-90
@github-actions github-actions Bot added backend Server-side business logic and API service pipeline built on .NET 8. mobile Cross-platform mobile client application for field workers and response teams. web docs labels Sep 9, 2026
…and Docker web orchestration

- Purged SonarScanner and Java dependencies from GitHub Actions
- Introduced root .editorconfig and enforced Roslyn recommended analyzers
- Integrated GitHub CodeQL SAST and Gitleaks secret scanning
- Added dedicated CI pipelines for Blazor WASM and expanded Flutter Mobile CI
- Created multi-stage Dockerfile and Nginx SPA routing for Blazor Web client
- Updated Nginx ingress gateway with dual upstreams (api and web SPA)
- Added JSON-file log rotation and resource limits to docker-compose
@Decuayer

Decuayer commented Sep 9, 2026

Copy link
Copy Markdown
Owner Author

📌 Summary of Changes

This pull request completely removes SonarQube/SonarCloud dependencies and establishes a self-contained, enterprise-grade static analysis and CI/CD ecosystem alongside a modern multi-container Docker deployment architecture.

🛡️ Quality Gates & Security (SonarQube Replacement)

  • Eliminated SonarQube: Dropped external SonarCloud token requirements, Java 17 CI installation, and SonarScanner overhead.
  • Root .editorconfig: Unified formatting rules across C# 12/.NET 10, Razor/HTML/CSS, and Dart.
  • Roslyn Analyzers: Activated latest-recommended analysis with EnforceCodeStyleInBuild=true in Directory.Build.props.
  • GitHub CodeQL SAST: Added native semantic security analysis for C# without third-party tools.
  • Gitleaks Secret Scanner: Automated detection of accidentally committed credentials.
  • ReportGenerator Step Summary: Formatted Cobertura code coverage directly into PR action summaries.

🚀 CI/CD Overhaul

  • Backend CI (backend-ci.yml): Parallelized into Secret Audit, Code Quality, Tests + Coverage Summary, and CodeQL.
  • Web CI (web-ci.yml): Added dedicated .NET 10 Blazor WASM build and release bundle verification.
  • Mobile CI (mobile-ci.yml): Strict Flutter analysis (--fatal-infos), test coverage reporting, and Android APK / Web build dry-runs.
  • CD (backend-cd.yml): Integrated hadolint Dockerfile validation, Trivy container CVE scanning, and multi-image GHCR publishing with GHA buildx cache.

🐳 Docker & Infrastructure Modernization

  • Blazor WASM Container: Added multi-stage build (dotnet:10.0-alpine -> nginx:alpine) with WebAssembly MIME types, gzip compression, and immutable cache headers.
  • Nginx Ingress Proxy: Configured dual upstreams routing / to the Blazor WASM SPA, /api/ to the backend REST API, and /hubs/ with 3600s timeout to SignalR WebSockets.
  • Docker Compose (Dev & Prod): Configured json-file log rotation (max-size: 10m, max-file: 3), production CPU/RAM quotas, and container healthchecks.

🧪 Verification Results

  • docker compose -f docker-compose.yml config: PASSED (Exit Code 0)
  • docker compose -f docker/docker-compose.prod.yml config: PASSED (Exit Code 0)
  • dotnet build backend/SocarDispatch.slnx: PASSED (0 Errors, 0 Warnings)
  • dotnet format backend/SocarDispatch.slnx whitespace --verify-no-changes: PASSED (Exit Code 0)
  • dotnet test backend/SocarDispatch.slnx: PASSED (202/202 Tests Passed)
  • dotnet build clients/web/SocarDispatch.Web/SocarDispatch.Web.csproj: PASSED (0 Errors, 0 Warnings)
  • flutter analyze clients/mobile: PASSED (No issues found!)
  • flutter test clients/mobile: PASSED (86/86 Tests Passed)

@Decuayer
Decuayer merged commit 2f59cb2 into main Sep 24, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Server-side business logic and API service pipeline built on .NET 8. ci docs infra mobile Cross-platform mobile client application for field workers and response teams. web

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant