From a107b4d9e2f7d0db3db833638e483f269c4226ed Mon Sep 17 00:00:00 2001 From: Nathan Mattes Date: Mon, 19 Dec 2022 13:05:51 +0100 Subject: [PATCH] Consider password-confirmation on signup (#690) This is now the logic-part. The passwords must be the same to register. --- .../Register/MastodonRegisterViewModel.swift | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Mastodon/Scene/Onboarding/Register/MastodonRegisterViewModel.swift b/Mastodon/Scene/Onboarding/Register/MastodonRegisterViewModel.swift index 5d3f5eb0d..a165716c2 100644 --- a/Mastodon/Scene/Onboarding/Register/MastodonRegisterViewModel.swift +++ b/Mastodon/Scene/Onboarding/Register/MastodonRegisterViewModel.swift @@ -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)