Skip to content

Commit

Permalink
Remove unnecessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
Sjmarf committed Jan 20, 2024
1 parent c2f59e0 commit 401add5
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions Mlem/API/APIClient/APIClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,11 @@ class APIClient {
definition.headers.forEach { header in
urlRequest.setValue(header.value, forHTTPHeaderField: header.key)
}

if !definition.headers.keys.contains("Authorization") {
if let overrideToken {
urlRequest.setValue("Bearer \(overrideToken)", forHTTPHeaderField: "Authorization")
} else if case let .authenticated(_, token) = session, try session.instanceUrl == definition.instanceURL {
urlRequest.setValue("Bearer \(token)", forHTTPHeaderField: "Authorization")
}

if let overrideToken {
urlRequest.setValue("Bearer \(overrideToken)", forHTTPHeaderField: "Authorization")
} else if case let .authenticated(_, token) = session, try session.instanceUrl == definition.instanceURL {
urlRequest.setValue("Bearer \(token)", forHTTPHeaderField: "Authorization")
}

if definition as? any APIGetRequest != nil {
Expand Down

0 comments on commit 401add5

Please sign in to comment.