Skip to content

Commit

Permalink
Fixed login error detection
Browse files Browse the repository at this point in the history
  • Loading branch information
TheM4hd1 committed Nov 12, 2020
1 parent e889f65 commit c4b4378
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions SwiftyInsta/API/Handlers/AuthenticationHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -136,18 +136,23 @@ final class AuthenticationHandler: Handler {
data: cookies.data)
// actually authenticate.
handler.authenticate(with: .cache(cache), completionHandler: completionHandler)
} else if response.invalidCredentials ?? false {
if let errorType = response.errorType {
if errorType.elementsEqual("invalid_user") {
user.response = .failure
handler.settings.queues.response.async {
completionHandler(.failure(AuthenticationError.invalidUsername))
}
} else {
user.response = .failure
handler.settings.queues.response.async {
completionHandler(.failure(AuthenticationError.invalidPassword))
}
} else {
user.response = .failure
handler.settings.queues.response.async {
completionHandler(.failure(GenericError.custom("Unknown error.")))
}
}
} else if response.invalidCredentials ?? false {
if let errorType = response.errorType {
if errorType.elementsEqual("invalid_user") {
user.response = .failure
handler.settings.queues.response.async {
completionHandler(.failure(AuthenticationError.invalidUsername))
}
} else {
user.response = .failure
handler.settings.queues.response.async {
completionHandler(.failure(AuthenticationError.invalidPassword))
}
}
}
Expand Down

0 comments on commit c4b4378

Please sign in to comment.