mirror of
https://github.com/XcodesOrg/XcodesApp.git
synced 2026-04-27 15:07:39 +00:00
Merge branch 'main' into matt/nonPaidAppleDeveloper
This commit is contained in:
commit
4db8346c2f
1 changed files with 11 additions and 1 deletions
|
|
@ -148,7 +148,14 @@ public class Client {
|
||||||
/// Use the olympus session endpoint to see if the existing session is still valid
|
/// Use the olympus session endpoint to see if the existing session is still valid
|
||||||
public func validateSession() -> AnyPublisher<Void, Error> {
|
public func validateSession() -> AnyPublisher<Void, Error> {
|
||||||
return Current.network.dataTask(with: URLRequest.olympusSession)
|
return Current.network.dataTask(with: URLRequest.olympusSession)
|
||||||
.map(\.data)
|
.tryMap { result -> Data in
|
||||||
|
let httpResponse = result.response as! HTTPURLResponse
|
||||||
|
if httpResponse.statusCode == 401 {
|
||||||
|
throw AuthenticationError.notAuthorized
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.data
|
||||||
|
}
|
||||||
.decode(type: AppleSession.self, decoder: JSONDecoder())
|
.decode(type: AppleSession.self, decoder: JSONDecoder())
|
||||||
.tryMap { session in
|
.tryMap { session in
|
||||||
// A user that is a non-paid Apple Developer will have a provider == nil
|
// A user that is a non-paid Apple Developer will have a provider == nil
|
||||||
|
|
@ -192,6 +199,7 @@ public enum AuthenticationError: Swift.Error, LocalizedError, Equatable {
|
||||||
case accountLocked(String)
|
case accountLocked(String)
|
||||||
case badStatusCode(statusCode: Int, data: Data, response: HTTPURLResponse)
|
case badStatusCode(statusCode: Int, data: Data, response: HTTPURLResponse)
|
||||||
case notDeveloperAppleId
|
case notDeveloperAppleId
|
||||||
|
case notAuthorized
|
||||||
|
|
||||||
public var errorDescription: String? {
|
public var errorDescription: String? {
|
||||||
switch self {
|
switch self {
|
||||||
|
|
@ -220,6 +228,8 @@ public enum AuthenticationError: Swift.Error, LocalizedError, Equatable {
|
||||||
return "Received an unexpected status code: \(statusCode). If you continue to have problems, please submit a bug report in the Help menu."
|
return "Received an unexpected status code: \(statusCode). If you continue to have problems, please submit a bug report in the Help menu."
|
||||||
case .notDeveloperAppleId:
|
case .notDeveloperAppleId:
|
||||||
return "You are not registered as an Apple Developer. Please visit Apple Developer Registration. https://developer.apple.com/register/"
|
return "You are not registered as an Apple Developer. Please visit Apple Developer Registration. https://developer.apple.com/register/"
|
||||||
|
case .notAuthorized:
|
||||||
|
return "You are not authorized. Please Sign in with your Apple ID first."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue