Phase 2 aus dem Native-Auth-Vollausbau-Plan (Option A, siehe ../mana/docs/MANA_SWIFT.md). Entstanden weil drei Apps fast- byte-identische LoginView.swift hatten und Sign-Up/Forgot-PW komplett fehlten. ManaAuthUI-Library mit: - ManaBrandConfig — App-injizierte Theme-Werte (forest für Cards/ Manaspur, mana-default für Memoro), Environment-Key, View-Modifier - Base-Components: ManaAuthScaffold, ManaPrimaryButton, ManaTextField, ManaSecureField + .manaEmailField()-Modifier - ManaLoginView + LoginViewModel — Email/PW-Login, schaltet bei AuthError.emailNotVerified automatisch auf ManaEmailVerifyGateView - ManaSignUpView + SignUpViewModel — Email/Name/PW + awaiting- Verification-Hinweis-Screen - ManaEmailVerifyGateView + ViewModel — Resend-Verification - ManaForgotPasswordView + ViewModel — Reset-Mail anfordern (immer generischer Hinweis, User-Enumeration-Schutz) - ManaResetPasswordView + ViewModel — neues PW mit Token aus Universal-Link - ManaChangeEmailView, ManaChangePasswordView, ManaDeleteAccountView + internal ViewModels — Account-Bausteine - ManaDeleteAccountView ist zweistufig (Bestätigungs-Wort tippen + Passwort) → App-Store-Guideline 5.1.1(v) Pflicht-Surface 26/26 ViewModel-Tests grün via per-test-ID URLProtocol-Routing (löst Parallel-Pollution zwischen .serialized Suites). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
50 lines
1.4 KiB
Swift
50 lines
1.4 KiB
Swift
import Foundation
|
|
import ManaCore
|
|
import Observation
|
|
|
|
/// State-Maschine für ``ManaEmailVerifyGateView``. Wraps
|
|
/// `AuthClient.resendVerification`.
|
|
@MainActor
|
|
@Observable
|
|
public final class EmailVerifyGateViewModel {
|
|
public enum Status: Equatable, Sendable {
|
|
case idle
|
|
case resending
|
|
case resent(String)
|
|
case error(String)
|
|
}
|
|
|
|
public let email: String
|
|
public private(set) var status: Status = .idle
|
|
|
|
private let auth: AuthClient
|
|
private let sourceAppUrl: URL?
|
|
|
|
public init(email: String, auth: AuthClient, sourceAppUrl: URL? = nil) {
|
|
self.email = email
|
|
self.auth = auth
|
|
self.sourceAppUrl = sourceAppUrl
|
|
}
|
|
|
|
public var canResend: Bool {
|
|
if case .resending = status { return false }
|
|
return true
|
|
}
|
|
|
|
public var isResending: Bool {
|
|
if case .resending = status { return true }
|
|
return false
|
|
}
|
|
|
|
public func resend() async {
|
|
status = .resending
|
|
do {
|
|
try await auth.resendVerification(email: email, sourceAppUrl: sourceAppUrl)
|
|
status = .resent("Bestätigungs-Mail wurde verschickt. Schau in deinen Posteingang.")
|
|
} catch let error as AuthError {
|
|
status = .error(error.errorDescription ?? "Senden fehlgeschlagen")
|
|
} catch {
|
|
status = .error(String(describing: error))
|
|
}
|
|
}
|
|
}
|