mirror of
https://github.com/writeas/writefreely-swiftui-multiplatform.git
synced 2024-11-15 01:11:02 +00:00
Add logic for AccountError.invalidServerURL case when logging in
This commit is contained in:
parent
1a8951a3e0
commit
6da33e22cc
@ -62,7 +62,6 @@ struct AccountLoginView: View {
|
|||||||
if !(server.hasPrefix("https://") || server.hasPrefix("http://")) {
|
if !(server.hasPrefix("https://") || server.hasPrefix("http://")) {
|
||||||
server = "https://\(server)"
|
server = "https://\(server)"
|
||||||
}
|
}
|
||||||
print(server)
|
|
||||||
// We only need the protocol and host from the URL, so drop anything else.
|
// We only need the protocol and host from the URL, so drop anything else.
|
||||||
let url = URLComponents(string: server)
|
let url = URLComponents(string: server)
|
||||||
if let validURL = url {
|
if let validURL = url {
|
||||||
@ -73,7 +72,8 @@ struct AccountLoginView: View {
|
|||||||
hostURL.host = host
|
hostURL.host = host
|
||||||
server = hostURL.string ?? server
|
server = hostURL.string ?? server
|
||||||
} else {
|
} else {
|
||||||
// TODO: - throw an error if this is an invalid URL.
|
model.loginErrorMessage = AccountError.invalidServerURL.localizedDescription
|
||||||
|
model.isPresentingLoginErrorAlert = true
|
||||||
}
|
}
|
||||||
model.login(
|
model.login(
|
||||||
to: URL(string: server)!,
|
to: URL(string: server)!,
|
||||||
|
@ -5,6 +5,7 @@ enum AccountError: Error {
|
|||||||
case invalidPassword
|
case invalidPassword
|
||||||
case usernameNotFound
|
case usernameNotFound
|
||||||
case serverNotFound
|
case serverNotFound
|
||||||
|
case invalidServerURL
|
||||||
}
|
}
|
||||||
|
|
||||||
extension AccountError: LocalizedError {
|
extension AccountError: LocalizedError {
|
||||||
@ -25,6 +26,11 @@ extension AccountError: LocalizedError {
|
|||||||
"Username not found. Did you use your email address by mistake?",
|
"Username not found. Did you use your email address by mistake?",
|
||||||
comment: ""
|
comment: ""
|
||||||
)
|
)
|
||||||
|
case .invalidServerURL:
|
||||||
|
return NSLocalizedString(
|
||||||
|
"The server entered doesn't appear to be a valid URL. Please check what you've entered and try again.",
|
||||||
|
comment: ""
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user