|
@@ -79,10 +79,10 @@ class KMSignUpViewModel: ObservableObject {
|
|
|
}
|
|
|
|
|
|
func countDown(type: KMVerificationCodeType, count: Int = 60) -> Void {
|
|
|
- getVerificationCode(type)
|
|
|
- if emailErrorMessage.count > 0 {
|
|
|
+ if emailErrorMessage.count > 0 || !isValidEmail() {
|
|
|
return
|
|
|
}
|
|
|
+ getVerificationCode(type)
|
|
|
|
|
|
sendBoxSelect = true
|
|
|
remainingSeconds = count
|
|
@@ -122,12 +122,10 @@ class KMSignUpViewModel: ObservableObject {
|
|
|
return false
|
|
|
}
|
|
|
|
|
|
- // MARK: Private Method
|
|
|
-
|
|
|
/**
|
|
|
@abstract 验证邮箱是否合规
|
|
|
*/
|
|
|
- private func isValidEmail() -> Bool {
|
|
|
+ func isValidEmail() -> Bool {
|
|
|
let emailRegex = "^[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$"
|
|
|
let emailTest = NSPredicate(format: "SELF MATCHES %@", emailRegex)
|
|
|
return emailTest.evaluate(with: email)
|
|
@@ -136,12 +134,14 @@ class KMSignUpViewModel: ObservableObject {
|
|
|
/**
|
|
|
@abstract 验证验证码是否合规
|
|
|
*/
|
|
|
- private func isValidVerificationCode() -> Bool {
|
|
|
+ func isValidVerificationCode() -> Bool {
|
|
|
let pattern = "^\\d{6}$"
|
|
|
let regex = try! NSRegularExpression(pattern: pattern)
|
|
|
return regex.firstMatch(in: verificationCode, options: [], range: NSRange(location: 0, length: verificationCode.utf16.count)) != nil
|
|
|
}
|
|
|
|
|
|
+ // MARK: Private Method
|
|
|
+
|
|
|
/**
|
|
|
@abstract 刷新用户个人信息
|
|
|
*/
|
|
@@ -171,7 +171,7 @@ class KMSignUpViewModel: ObservableObject {
|
|
|
|
|
|
var code: String = ""
|
|
|
if signUpState == .verificationCode {
|
|
|
- if verificationCode.count <= 0 || verificationCode.count > 6 {
|
|
|
+ if verificationCode.count <= 0 || verificationCode.count > 6 || !isValidVerificationCode() {
|
|
|
passwordErrorMessage = NSLocalizedString("*Please enter right Verification code", tableName: "MemberCenterLocalizable", comment: "")
|
|
|
return
|
|
|
}
|
|
@@ -269,12 +269,7 @@ class KMSignUpViewModel: ObservableObject {
|
|
|
@param
|
|
|
*/
|
|
|
func enterVerificationCodeNextAction(_ complete: @escaping ForgotPasswordComplete) -> Void {
|
|
|
- if verificationCode.count <= 0 {
|
|
|
- emailErrorMessage = NSLocalizedString("*Please enter right Verification code", tableName: "MemberCenterLocalizable", comment: "")
|
|
|
- complete(false, "")
|
|
|
- return
|
|
|
- }
|
|
|
- if !isValidVerificationCode() {
|
|
|
+ if verificationCode.count <= 0 || !isValidVerificationCode() {
|
|
|
emailErrorMessage = NSLocalizedString("*Please enter right Verification code", tableName: "MemberCenterLocalizable", comment: "")
|
|
|
complete(false, "")
|
|
|
return
|