v0.1.0 — initialer Sprint, vollständige Auth-Reise als SwiftUI
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>
This commit is contained in:
commit
0a2cb349b4
29 changed files with 2614 additions and 0 deletions
50
Sources/ManaAuthUI/Verify/EmailVerifyGateViewModel.swift
Normal file
50
Sources/ManaAuthUI/Verify/EmailVerifyGateViewModel.swift
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
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))
|
||||
}
|
||||
}
|
||||
}
|
||||
83
Sources/ManaAuthUI/Verify/ManaEmailVerifyGateView.swift
Normal file
83
Sources/ManaAuthUI/Verify/ManaEmailVerifyGateView.swift
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
import ManaCore
|
||||
import SwiftUI
|
||||
|
||||
/// Wird angezeigt, wenn ein Login-Versuch mit
|
||||
/// ``AuthError/emailNotVerified`` gescheitert ist. Bietet einen
|
||||
/// Resend-Mail-Button und einen "Zurück zum Login"-Pfad.
|
||||
///
|
||||
/// Die Apps bauen das nicht direkt ein — ``ManaLoginView`` schaltet
|
||||
/// automatisch um wenn der Sign-In den entsprechenden Fehler liefert.
|
||||
public struct ManaEmailVerifyGateView: View {
|
||||
@Environment(\.manaBrand) private var brand
|
||||
|
||||
@State private var model: EmailVerifyGateViewModel
|
||||
private let onBackToLogin: () -> Void
|
||||
|
||||
public init(
|
||||
email: String,
|
||||
auth: AuthClient,
|
||||
sourceAppUrl: URL? = nil,
|
||||
onBackToLogin: @escaping () -> Void
|
||||
) {
|
||||
_model = State(initialValue: EmailVerifyGateViewModel(
|
||||
email: email,
|
||||
auth: auth,
|
||||
sourceAppUrl: sourceAppUrl
|
||||
))
|
||||
self.onBackToLogin = onBackToLogin
|
||||
}
|
||||
|
||||
public var body: some View {
|
||||
ManaAuthScaffold {
|
||||
VStack(spacing: 16) {
|
||||
Image(systemName: "envelope.badge")
|
||||
.font(.system(size: 56, weight: .light))
|
||||
.foregroundStyle(brand.primary)
|
||||
.padding(.bottom, 8)
|
||||
|
||||
Text("Bestätige deine Email")
|
||||
.font(.title2)
|
||||
.fontWeight(.semibold)
|
||||
.foregroundStyle(brand.foreground)
|
||||
.multilineTextAlignment(.center)
|
||||
|
||||
Text(
|
||||
"Wir haben dir eine Bestätigungs-Mail an **\(model.email)** geschickt. "
|
||||
+ "Klicke den Link in der Mail, dann kannst du dich anmelden."
|
||||
)
|
||||
.font(.subheadline)
|
||||
.foregroundStyle(brand.mutedForeground)
|
||||
.multilineTextAlignment(.center)
|
||||
|
||||
ManaPrimaryButton(
|
||||
"Bestätigungs-Mail erneut senden",
|
||||
isLoading: model.isResending,
|
||||
isEnabled: model.canResend
|
||||
) {
|
||||
Task { await model.resend() }
|
||||
}
|
||||
.padding(.top, 8)
|
||||
|
||||
switch model.status {
|
||||
case let .resent(message):
|
||||
Text(message)
|
||||
.font(.footnote)
|
||||
.foregroundStyle(brand.success)
|
||||
.multilineTextAlignment(.center)
|
||||
case let .error(message):
|
||||
Text(message)
|
||||
.font(.footnote)
|
||||
.foregroundStyle(brand.error)
|
||||
.multilineTextAlignment(.center)
|
||||
default:
|
||||
EmptyView()
|
||||
}
|
||||
|
||||
Button("Zurück zum Login", action: onBackToLogin)
|
||||
.font(.subheadline)
|
||||
.foregroundStyle(brand.mutedForeground)
|
||||
.padding(.top, 16)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue