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>
127 lines
4.1 KiB
Swift
127 lines
4.1 KiB
Swift
import ManaCore
|
|
import SwiftUI
|
|
|
|
/// "Neues Passwort setzen"-Screen. Wird aus dem Universal-Link-Handler
|
|
/// der App aufgerufen, sobald der User den Reset-Link aus der Email
|
|
/// geklickt hat — die App extrahiert `?token=…` aus der URL und
|
|
/// präsentiert diesen View.
|
|
///
|
|
/// ```swift
|
|
/// // In App.handleUniversalLink:
|
|
/// if url.path == "/auth/reset", let token = url.queryToken {
|
|
/// showResetPasswordSheet(token: token)
|
|
/// }
|
|
/// ```
|
|
public struct ManaResetPasswordView: View {
|
|
@Environment(\.manaBrand) private var brand
|
|
@State private var model: ResetPasswordViewModel
|
|
private let onDone: () -> Void
|
|
|
|
/// - Parameters:
|
|
/// - token: Reset-Token aus der Email (`?token=…`).
|
|
/// - auth: gemeinsamer `AuthClient` der App.
|
|
/// - onDone: Callback bei Erfolg oder Abbruch — App schließt
|
|
/// den Sheet und navigiert zurück zum Login.
|
|
public init(
|
|
token: String,
|
|
auth: AuthClient,
|
|
onDone: @escaping () -> Void
|
|
) {
|
|
_model = State(initialValue: ResetPasswordViewModel(token: token, auth: auth))
|
|
self.onDone = onDone
|
|
}
|
|
|
|
public var body: some View {
|
|
switch model.status {
|
|
case .done:
|
|
doneView
|
|
default:
|
|
formView
|
|
}
|
|
}
|
|
|
|
@ViewBuilder
|
|
private var formView: some View {
|
|
ManaAuthScaffold {
|
|
VStack(spacing: 16) {
|
|
Text("Neues Passwort")
|
|
.font(.title2)
|
|
.fontWeight(.semibold)
|
|
.foregroundStyle(brand.foreground)
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
|
|
Text("Wähle ein neues Passwort. Mindestens 8 Zeichen.")
|
|
.font(.subheadline)
|
|
.foregroundStyle(brand.mutedForeground)
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
|
|
ManaSecureField(
|
|
"Neues Passwort",
|
|
text: $model.newPassword,
|
|
textContentType: .newPassword
|
|
)
|
|
|
|
ManaSecureField(
|
|
"Passwort bestätigen",
|
|
text: $model.confirmPassword,
|
|
textContentType: .newPassword
|
|
)
|
|
|
|
if let hint = model.validationHint {
|
|
Text(hint)
|
|
.font(.footnote)
|
|
.foregroundStyle(brand.mutedForeground)
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
}
|
|
|
|
ManaPrimaryButton(
|
|
"Passwort setzen",
|
|
isLoading: model.isSubmitting,
|
|
isEnabled: model.canSubmit
|
|
) {
|
|
Task { await model.submit() }
|
|
}
|
|
|
|
if case let .error(message) = model.status {
|
|
Text(message)
|
|
.font(.footnote)
|
|
.foregroundStyle(brand.error)
|
|
.multilineTextAlignment(.center)
|
|
.padding(.top, 4)
|
|
}
|
|
}
|
|
.padding(.top, 16)
|
|
|
|
Button("Abbrechen", action: onDone)
|
|
.font(.subheadline)
|
|
.foregroundStyle(brand.mutedForeground)
|
|
.padding(.top, 12)
|
|
}
|
|
}
|
|
|
|
@ViewBuilder
|
|
private var doneView: some View {
|
|
ManaAuthScaffold {
|
|
VStack(spacing: 16) {
|
|
Image(systemName: "lock.open.fill")
|
|
.font(.system(size: 56, weight: .light))
|
|
.foregroundStyle(brand.success)
|
|
|
|
Text("Passwort aktualisiert")
|
|
.font(.title2)
|
|
.fontWeight(.semibold)
|
|
.foregroundStyle(brand.foreground)
|
|
|
|
Text("Du kannst dich jetzt mit deinem neuen Passwort anmelden.")
|
|
.font(.subheadline)
|
|
.foregroundStyle(brand.mutedForeground)
|
|
.multilineTextAlignment(.center)
|
|
|
|
ManaPrimaryButton("Zum Login") {
|
|
onDone()
|
|
}
|
|
.padding(.top, 16)
|
|
}
|
|
}
|
|
}
|
|
}
|