Browse Source

change password language managed

pull/1/head
gme_2 6 years ago
parent
commit
ac7d2d5385
  1. 33
      GMERemittance/Profile/ProfileChangePasswordViewController.swift

33
GMERemittance/Profile/ProfileChangePasswordViewController.swift

@ -12,11 +12,24 @@ import UIKit
// there is not time to take this to viper archi. so applying mvc here.
class ProfileChangePasswordViewController: UIViewController {
struct StringConstants {
static let passwordErrorText = "password_policy_text".localized()
static let newPasswordTitleText = "new_password_text".localized()
static let currentPasswordTitleText = "current_password_text".localized()
static let confirmPasswordTitleText = "confirm_password_text".localized()
static let saveText = "save_text".localized()
static let titleText = "change_password_title_text".localized()
static let successText = "success_text".localized()
static let emptyPasswordError = "password_empty_error".localized()
static let passwordLengthError = "password_length_error".localized()
static let passwordPolicy = "password_policy_error".localized()
static let passwordMatchError = "password_match_error".localized()
}
@IBOutlet weak var textFieldCurrentPassword: UITextField!
@IBOutlet weak var textFieldNewPassword: UITextField!
@IBOutlet weak var textFieldConfirmPassword: UITextField!
@ -34,7 +47,7 @@ class ProfileChangePasswordViewController: UIViewController {
override func viewWillAppear(_ animated: Bool) {
super.viewWillDisappear(animated)
self.navigationItem.title = "Change Password"
self.navigationItem.title = StringConstants.titleText
}
override func viewWillDisappear(_ animated: Bool) {
@ -65,7 +78,7 @@ class ProfileChangePasswordViewController: UIViewController {
func updatePassword(param: [String: String]) {
self.updatePassword(params: param, success: { (message) in
self.alert(message: message, title: "Success", okAction: {
self.alert(message: message, title: StringConstants.successText, okAction: {
self.navigationController?.popViewController(animated: true)
})
}) { (error) in
@ -110,12 +123,12 @@ extension ProfileChangePasswordViewController {
if password.isEmpty {
error = error + "\n Password cannot be empty"
error = error + "\n \(StringConstants.emptyPasswordError)"
isValid = false
}else {
if !isValidLength() {
error = error + "\n Password should have at least 9 characters"
error = error + "\n \(StringConstants.passwordLengthError)"
isValid = false
return (isValid, error)
}
@ -124,12 +137,12 @@ extension ProfileChangePasswordViewController {
if !validPassword {
isValid = false
error = error + "\n Password should contain at least one symbol, one capital letter and one number"
error = error + "\n \(StringConstants.passwordLengthError)"
return (isValid, error)
}
if password != confirmPassword {
error = error + "\n Passwords does not match."
error = error + "\n \(StringConstants.passwordMatchError)"
isValid = false
}
}
@ -144,7 +157,7 @@ extension ProfileChangePasswordViewController {
// user name
if currentPassword.isEmpty {
error = error + "current password field is required.";
error = error + "\(StringConstants.emptyPasswordError)";
isValid = false
}

Loading…
Cancel
Save