|
|
@ -20,7 +20,7 @@ class ProfileChangePasswordViewController: UIViewController { |
|
|
|
let passwordErrorText = "password_error_text".localized() |
|
|
|
|
|
|
|
let saveText = "save_text".localized() |
|
|
|
let titleText = "change_password_title_text".localized() |
|
|
|
let titleText = "change_password_text".localized() |
|
|
|
let successText = "success_text".localized() |
|
|
|
let emptyPasswordError = "password_empty_error".localized() |
|
|
|
let confirmPasswordError = "password_confirm_empty_error".localized() |
|
|
@ -76,9 +76,9 @@ class ProfileChangePasswordViewController: UIViewController { |
|
|
|
self.textFieldConfirmPassword.isSecureTextEntry = true |
|
|
|
self.textFieldCurrentPassword.isSecureTextEntry = true |
|
|
|
|
|
|
|
textFieldCurrentPassword.validCondition = { !$0.isEmpty && $0.validateRegex(regex: #"^(?=.*[A-Z])(?=.*[0-9])(?=.*[a-z]).{8,24}$"#)} |
|
|
|
textFieldNewPassword.validCondition = { !$0.isEmpty && $0.validateRegex(regex: #"^(?=.*[A-Z])(?=.*[0-9])(?=.*[a-z]).{8,24}$"#)} |
|
|
|
textFieldConfirmPassword.validCondition = { !$0.isEmpty && $0.validateRegex(regex: #"^(?=.*[A-Z])(?=.*[0-9])(?=.*[a-z]).{8,24}$"#)} |
|
|
|
textFieldCurrentPassword.validCondition = { !$0.isEmpty && $0.validateRegex(regex: passwordRegex)} |
|
|
|
textFieldNewPassword.validCondition = { !$0.isEmpty && $0.validateRegex(regex: passwordRegex)} |
|
|
|
textFieldConfirmPassword.validCondition = { !$0.isEmpty && $0.validateRegex(regex: passwordRegex)} |
|
|
|
|
|
|
|
textFieldNewPassword.addTarget(self, action: #selector(editingChanged(_:)), for: .editingChanged) |
|
|
|
textFieldConfirmPassword.addTarget(self, action: #selector(editingChanged(_:)), for: .editingChanged) |
|
|
@ -167,11 +167,11 @@ extension ProfileChangePasswordViewController { |
|
|
|
var error = "" |
|
|
|
var isValid = true |
|
|
|
|
|
|
|
if password.isEmpty { |
|
|
|
if !password.validateRegex(regex: passwordRegex){ |
|
|
|
error = "\(error)\n\(StringConstants().emptyPasswordError)" |
|
|
|
isValid = false |
|
|
|
} |
|
|
|
if confirmPassword.isEmpty { |
|
|
|
if !confirmPassword.validateRegex(regex: passwordRegex){ |
|
|
|
error = "\(error)\n\(StringConstants().emptyPasswordError)" |
|
|
|
isValid = false |
|
|
|
} |
|
|
@ -189,7 +189,7 @@ extension ProfileChangePasswordViewController { |
|
|
|
var isValid = true |
|
|
|
// user name |
|
|
|
|
|
|
|
if currentPassword.isEmpty { |
|
|
|
if !currentPassword.validateRegex(regex: passwordRegex){ |
|
|
|
error = "\(error)\n\(StringConstants().emptyPasswordError)" |
|
|
|
isValid = false |
|
|
|
} |
|
|
@ -268,6 +268,6 @@ extension ProfileChangePasswordViewController { |
|
|
|
default: |
|
|
|
break |
|
|
|
} |
|
|
|
self.isValid = (encryptedOldPassword != "" && encryptedPassword != "" && encryptedConfirmPassword != "") |
|
|
|
self.isValid = (encryptedOldPassword.validateRegex(regex: passwordRegex) && encryptedPassword.validateRegex(regex: passwordRegex) && encryptedConfirmPassword.validateRegex(regex: passwordRegex) ) |
|
|
|
} |
|
|
|
} |