diff --git a/ios-base/Common/Models/Session.swift b/ios-base/Common/Models/Session.swift index b8e6370..ffa3710 100644 --- a/ios-base/Common/Models/Session.swift +++ b/ios-base/Common/Models/Session.swift @@ -33,18 +33,15 @@ struct Session: Codable { self.expiry = expires } - init?(headers: [String: Any]) { - var loweredHeaders = headers - loweredHeaders.lowercaseKeys() - guard let stringHeaders = loweredHeaders as? [String: String] else { - return nil - } - if let expiryString = stringHeaders[APIClient.HTTPHeader.expiry.rawValue], + init?(headers: [String: String]) { + var loweredKeysHeaders = headers + loweredKeysHeaders.lowercaseKeys() + if let expiryString = loweredKeysHeaders[APIClient.HTTPHeader.expiry.rawValue], let expiryNumber = Double(expiryString) { expiry = Date(timeIntervalSince1970: expiryNumber) } - uid = stringHeaders[APIClient.HTTPHeader.uid.rawValue] - client = stringHeaders[APIClient.HTTPHeader.client.rawValue] - accessToken = stringHeaders[APIClient.HTTPHeader.token.rawValue] + uid = loweredKeysHeaders[APIClient.HTTPHeader.uid.rawValue] + client = loweredKeysHeaders[APIClient.HTTPHeader.client.rawValue] + accessToken = loweredKeysHeaders[APIClient.HTTPHeader.token.rawValue] } } diff --git a/ios-base/Networking/Services/AuthenticationServices.swift b/ios-base/Networking/Services/AuthenticationServices.swift index 1e31cec..57ce36d 100644 --- a/ios-base/Networking/Services/AuthenticationServices.swift +++ b/ios-base/Networking/Services/AuthenticationServices.swift @@ -151,7 +151,7 @@ class AuthenticationServices { UserDataManager.currentUser = User( dictionary: response["user"] as? [String: Any] ?? [:] ) - if let headers = headers as? [String: Any] { + if let headers = headers as? [String: String] { SessionManager.currentSession = Session(headers: headers) } }