fix register flow

This commit is contained in:
anlicheng 2026-03-19 20:13:50 +08:00
parent 4c9bb58a88
commit fd87c244b9
2 changed files with 12 additions and 2 deletions

View File

@ -34,6 +34,16 @@ struct SDLUtil {
} }
return digest.map { String(format: "%02x", $0) }.joined() return digest.map { String(format: "%02x", $0) }.joined()
}
static func isValidIdentifyContact(_ input: String) -> Bool {
switch identifyContact(input) {
case .email, .phone:
true
default:
false
}
} }
static func identifyContact(_ input: String) -> ContactType { static func identifyContact(_ input: String) -> ContactType {
@ -41,7 +51,7 @@ struct SDLUtil {
// 1 11 // 1 11
let phoneRegex = /^1[3-9][0-9]{9}$/ let phoneRegex = /^1[3-9][0-9]{9}$/
// //
let emailRegex = /^[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$/ let emailRegex = /^[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,64}$/
if trimmed.wholeMatch(of: phoneRegex) != nil { if trimmed.wholeMatch(of: phoneRegex) != nil {
return .phone return .phone
} else if trimmed.wholeMatch(of: emailRegex) != nil { } else if trimmed.wholeMatch(of: emailRegex) != nil {

View File

@ -102,7 +102,7 @@ struct RegisterRequestVerifyCodeView: View {
.buttonStyle(.borderedProminent) .buttonStyle(.borderedProminent)
.controlSize(.large) .controlSize(.large)
.frame(width: 280) .frame(width: 280)
.disabled(username.isEmpty || isProcessing) .disabled(!SDLUtil.isValidIdentifyContact(username) || isProcessing)
Spacer() Spacer()
} }