Consider password-confirmation on signup (#690)

This is now the logic-part. The passwords must be the same to register.
This commit is contained in:
Nathan Mattes 2022-12-19 13:05:51 +01:00
parent f3c8c3c2a3
commit a107b4d9e2
1 changed files with 8 additions and 3 deletions

View File

@ -150,10 +150,15 @@ final class MastodonRegisterViewModel: ObservableObject {
.assign(to: \.emailValidateState, on: self)
.store(in: &disposeBag)
$password
.map { password in
Publishers.CombineLatest($password, $passwordConfirmation)
.map { password, confirmation in
guard !password.isEmpty else { return .empty }
return password.count >= 8 ? .valid : .invalid
if password.count >= 8 && password == confirmation {
return .valid
} else {
return .invalid
}
}
.assign(to: \.passwordValidateState, on: self)
.store(in: &disposeBag)