Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 17 additions & 19 deletions PennMobile.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

329 changes: 0 additions & 329 deletions PennMobile/Auth/OAuth2NetworkManager.swift

This file was deleted.

2 changes: 1 addition & 1 deletion PennMobile/Auth/PennLoginController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class PennLoginController: UIViewController, WKUIDelegate, WKNavigationDelegate
self.activityIndicator.stopAnimating()
}

if self.isSuccessfulRedirect(url: url.absoluteString, hasReferer: true), response.statusCode == 200 {
if self.isSuccessfulRedirect(url: url.absoluteString, hasReferer: true), (200..<300).contains(response.statusCode) {
self.handleSuccessfulNavigation(webView) { (policy) in
decisionHandler(policy == WKNavigationActionPolicy.allow ? WKNavigationResponsePolicy.allow : WKNavigationResponsePolicy.cancel)
}
Expand Down
20 changes: 2 additions & 18 deletions PennMobile/Clubs/TicketingAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,8 @@ class TicketingAPI {
return URL(string: "\(baseURL)/api/tickets/\(pathComponent)/")
}

func getSession() async throws -> URLSession {
guard let accessToken = try? await OAuth2NetworkManager.instance.getAccessToken() else {
throw NetworkingError.authenticationError
}

// HACK: iOS doesn't preserve Authorization headers during redirects
// (It also doesn't support setting Authorization headers in general apparently)
let config = URLSessionConfiguration.default
config.httpAdditionalHeaders = [
"Authorization": "Bearer \(accessToken.value)",
"X-Authorization": "Bearer \(accessToken.value)"
]

return URLSession(configuration: config)
}

func getTicket(id: String) async throws -> Ticket? {
let session = try await getSession()
let session = try await URLSession(authenticationMode: .accessToken)

guard let url = ticketUrl(forId: id) else {
return nil
Expand All @@ -76,7 +60,7 @@ class TicketingAPI {
}

@discardableResult func updateAttendance(id: String, to attended: Bool) async throws -> Ticket {
let session = try await getSession()
let session = try await URLSession(authenticationMode: .accessToken)

guard let url = ticketUrl(forId: id) else {
throw ScannedTicket.InvalidReason.notFound
Expand Down
Loading