-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[Feat] 소셜로그인 구현
- Loading branch information
Showing
8 changed files
with
267 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,4 @@ struct ErrorResponse: Codable { | |
let code: Int | ||
let message: String | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// | ||
// LoginService.swift | ||
// KkuMulKum | ||
// | ||
// Created by 이지훈 on 7/15/24. | ||
// | ||
|
||
import Foundation | ||
|
||
import Moya | ||
|
||
enum LoginTargetType { | ||
case appleLogin(identityToken: String, fcmToken: String) | ||
case kakaoLogin(accessToken: String, fcmToken: String) | ||
} | ||
|
||
extension LoginTargetType: TargetType { | ||
var baseURL: URL { | ||
guard let privacyInfo = Bundle.main.privacyInfo, | ||
let urlString = privacyInfo["BASE_URL"] as? String, | ||
let url = URL(string: urlString) else { | ||
fatalError("Invalid BASE_URL in PrivacyInfo.plist") | ||
} | ||
return url | ||
} | ||
|
||
var path: String { | ||
return "/api/v1/auth/signin" | ||
} | ||
|
||
var method: Moya.Method { | ||
return .post | ||
} | ||
|
||
var task: Task { | ||
switch self { | ||
case let .appleLogin(_, fcmToken): | ||
return .requestParameters( | ||
parameters: ["provider": "APPLE", "fcmToken": fcmToken], | ||
encoding: JSONEncoding.default | ||
) | ||
case let .kakaoLogin(_, fcmToken): | ||
return .requestParameters( | ||
parameters: ["provider": "KAKAO", "fcmToken": fcmToken], | ||
encoding: JSONEncoding.default | ||
) | ||
} | ||
} | ||
|
||
var headers: [String : String]? { | ||
switch self { | ||
case .appleLogin(let identityToken, _): | ||
return ["Authorization": identityToken, "Content-Type": "application/json"] | ||
case .kakaoLogin(let accessToken, _): | ||
return ["Authorization": accessToken, "Content-Type": "application/json"] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// Bundle.swift | ||
// KkuMulKum | ||
// | ||
// Created by 이지훈 on 7/15/24. | ||
// | ||
|
||
import Foundation | ||
|
||
extension Bundle { | ||
var privacyInfo: [String: Any]? { | ||
guard let url = self.url(forResource: "PrivacyInfo", withExtension: "plist"), | ||
let data = try? Data(contentsOf: url), | ||
let result = try? PropertyListSerialization.propertyList( | ||
from: data, | ||
options: [], | ||
format: nil | ||
) as? [String: Any] else { | ||
return nil | ||
} | ||
return result | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.