From 44c11eb61078eeee6db65213b77e218618f2e534 Mon Sep 17 00:00:00 2001 From: chopmozzi <44396392+chopmozzi@users.noreply.github.com> Date: Mon, 22 Jan 2024 22:37:13 +0900 Subject: [PATCH 1/4] =?UTF-8?q?:bug:=20refresh=20bug=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 540415f59fb64a59780736884ea10f3ab0e7d8a3) --- iOS/Layover/Layover/Network/Provider/Provider.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/iOS/Layover/Layover/Network/Provider/Provider.swift b/iOS/Layover/Layover/Network/Provider/Provider.swift index ce709d4..f72e3ad 100644 --- a/iOS/Layover/Layover/Network/Provider/Provider.swift +++ b/iOS/Layover/Layover/Network/Provider/Provider.swift @@ -83,7 +83,9 @@ class Provider: ProviderType { var urlRequest = try endPoint.makeURLRequest() if authenticationIfNeeded { - if let token = authManager.accessToken { + if retryCount > 1, let token = authManager.accessToken { + urlRequest.setValue("Bearer \(token)", forHTTPHeaderField: "Authorization") + } else if let token = authManager.refreshToken { urlRequest.setValue("Bearer \(token)", forHTTPHeaderField: "Authorization") } else { guard await refreshTokenIfNeeded(), let newToken = authManager.accessToken else { From 063c3f35a529e2e6cffa29ecc8006bbc9f87f2e7 Mon Sep 17 00:00:00 2001 From: chopmozzi <44396392+chopmozzi@users.noreply.github.com> Date: Tue, 23 Jan 2024 00:30:20 +0900 Subject: [PATCH 2/4] =?UTF-8?q?:bug:=20Refresh=20EndPoint=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=EC=8B=9C=20Header=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit c7a49fc65c2a77c9373e86c0ebfe3cd03caaed67) --- iOS/Layover/Layover/Network/DTOs/LoginDTO.swift | 5 +++++ .../Network/EndPoint/Factories/LoginEndPointFactory.swift | 7 +++---- iOS/Layover/Layover/Network/Provider/Provider.swift | 4 +--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/iOS/Layover/Layover/Network/DTOs/LoginDTO.swift b/iOS/Layover/Layover/Network/DTOs/LoginDTO.swift index 0cc766b..1553240 100644 --- a/iOS/Layover/Layover/Network/DTOs/LoginDTO.swift +++ b/iOS/Layover/Layover/Network/DTOs/LoginDTO.swift @@ -12,3 +12,8 @@ struct LoginDTO: Decodable { let accessToken: String let refreshToken: String } + +struct TestDTO: Decodable { + let accessToken: String? + let refreshToken: String? +} diff --git a/iOS/Layover/Layover/Network/EndPoint/Factories/LoginEndPointFactory.swift b/iOS/Layover/Layover/Network/EndPoint/Factories/LoginEndPointFactory.swift index 1d1b2bc..0987cc3 100644 --- a/iOS/Layover/Layover/Network/EndPoint/Factories/LoginEndPointFactory.swift +++ b/iOS/Layover/Layover/Network/EndPoint/Factories/LoginEndPointFactory.swift @@ -29,13 +29,12 @@ struct DefaultLoginEndPointFactory: LoginEndPointFactory { } func makeTokenRefreshEndPoint(with refreshToken: String) -> EndPoint> { - var bodyParameters = [String: String]() - bodyParameters.updateValue(refreshToken, forKey: "refreshToken") - +// var bodyParameters = [String: String]() +// bodyParameters.updateValue(refreshToken, forKey: "refreshToken") return EndPoint( path: "/oauth/refresh-token", method: .POST, - bodyParameters: bodyParameters + headers: ["Content-Type": "application/json", "Authorization": "Bearer \(refreshToken)"] ) } diff --git a/iOS/Layover/Layover/Network/Provider/Provider.swift b/iOS/Layover/Layover/Network/Provider/Provider.swift index f72e3ad..ce709d4 100644 --- a/iOS/Layover/Layover/Network/Provider/Provider.swift +++ b/iOS/Layover/Layover/Network/Provider/Provider.swift @@ -83,9 +83,7 @@ class Provider: ProviderType { var urlRequest = try endPoint.makeURLRequest() if authenticationIfNeeded { - if retryCount > 1, let token = authManager.accessToken { - urlRequest.setValue("Bearer \(token)", forHTTPHeaderField: "Authorization") - } else if let token = authManager.refreshToken { + if let token = authManager.accessToken { urlRequest.setValue("Bearer \(token)", forHTTPHeaderField: "Authorization") } else { guard await refreshTokenIfNeeded(), let newToken = authManager.accessToken else { From bc6a9e0895b78566634c5450f41f03b7f9a25cb0 Mon Sep 17 00:00:00 2001 From: chopmozzi <44396392+chopmozzi@users.noreply.github.com> Date: Tue, 23 Jan 2024 00:32:55 +0900 Subject: [PATCH 3/4] =?UTF-8?q?:wrench:=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit ef97a2304452b15e215ab02d60b1b58238fbb0af) --- iOS/Layover/Layover/Network/DTOs/LoginDTO.swift | 5 ----- 1 file changed, 5 deletions(-) diff --git a/iOS/Layover/Layover/Network/DTOs/LoginDTO.swift b/iOS/Layover/Layover/Network/DTOs/LoginDTO.swift index 1553240..0cc766b 100644 --- a/iOS/Layover/Layover/Network/DTOs/LoginDTO.swift +++ b/iOS/Layover/Layover/Network/DTOs/LoginDTO.swift @@ -12,8 +12,3 @@ struct LoginDTO: Decodable { let accessToken: String let refreshToken: String } - -struct TestDTO: Decodable { - let accessToken: String? - let refreshToken: String? -} From eaf99c5f921da640b9d2f4c81b97b7f9186452f6 Mon Sep 17 00:00:00 2001 From: chopmozzi <44396392+chopmozzi@users.noreply.github.com> Date: Tue, 23 Jan 2024 00:37:39 +0900 Subject: [PATCH 4/4] =?UTF-8?q?:wrench:=20=EC=A3=BC=EC=84=9D=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Network/EndPoint/Factories/LoginEndPointFactory.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/iOS/Layover/Layover/Network/EndPoint/Factories/LoginEndPointFactory.swift b/iOS/Layover/Layover/Network/EndPoint/Factories/LoginEndPointFactory.swift index 0987cc3..e511af7 100644 --- a/iOS/Layover/Layover/Network/EndPoint/Factories/LoginEndPointFactory.swift +++ b/iOS/Layover/Layover/Network/EndPoint/Factories/LoginEndPointFactory.swift @@ -29,8 +29,6 @@ struct DefaultLoginEndPointFactory: LoginEndPointFactory { } func makeTokenRefreshEndPoint(with refreshToken: String) -> EndPoint> { -// var bodyParameters = [String: String]() -// bodyParameters.updateValue(refreshToken, forKey: "refreshToken") return EndPoint( path: "/oauth/refresh-token", method: .POST,