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
12 changes: 12 additions & 0 deletions Runnect-iOS/Runnect-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
CE0D9FD329648DA300CEB5CD /* CustomAlertVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE0D9FD229648DA300CEB5CD /* CustomAlertVC.swift */; };
CE10065529680F7000FD31FB /* DepartureSearchingResponseDto.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE10065429680F7000FD31FB /* DepartureSearchingResponseDto.swift */; };
CE1006572968230800FD31FB /* DepartureLocationModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE1006562968230800FD31FB /* DepartureLocationModel.swift */; };
CE102C4829DB1D6B00E23E69 /* GetNewTokenResponseDto.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE102C4729DB1D6B00E23E69 /* GetNewTokenResponseDto.swift */; };
CE102C4A29DBAD3D00E23E69 /* AuthInterceptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE102C4929DBAD3D00E23E69 /* AuthInterceptor.swift */; };
CE146770296568DC00DCEA1B /* RunTrackingVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE14676F296568DC00DCEA1B /* RunTrackingVC.swift */; };
CE14677829658C7200DCEA1B /* Stopwatch.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE14677729658C7200DCEA1B /* Stopwatch.swift */; };
CE14677A2965A80700DCEA1B /* CustomBottomSheetVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE1467792965A80700DCEA1B /* CustomBottomSheetVC.swift */; };
Expand Down Expand Up @@ -130,6 +132,7 @@
CEC2A6902962B06C00160BF7 /* convertLocationObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEC2A68F2962B06C00160BF7 /* convertLocationObject.swift */; };
CEC2A6922962BE2900160BF7 /* DepartureSearchVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEC2A6912962BE2900160BF7 /* DepartureSearchVC.swift */; };
CECA695C296E61D6002AF05C /* PrivateCourseNotUploadedResponseDto.swift in Sources */ = {isa = PBXBuildFile; fileRef = CECA695B296E61D6002AF05C /* PrivateCourseNotUploadedResponseDto.swift */; };
CEE59FDA29DD6F7D00C791F1 /* Providers.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEE59FD929DD6F7D00C791F1 /* Providers.swift */; };
CEEC6B3A2961C4F300D00E1E /* CourseDrawingHomeVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEEC6B392961C4F300D00E1E /* CourseDrawingHomeVC.swift */; };
CEEC6B3C2961C51A00D00E1E /* CourseStorageVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEEC6B3B2961C51A00D00E1E /* CourseStorageVC.swift */; };
CEEC6B3E2961C53700D00E1E /* CourseDiscoveryVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEEC6B3D2961C53700D00E1E /* CourseDiscoveryVC.swift */; };
Expand Down Expand Up @@ -180,6 +183,8 @@
CE10065229680D4400FD31FB /* .gitkeep */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitkeep; sourceTree = "<group>"; };
CE10065429680F7000FD31FB /* DepartureSearchingResponseDto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DepartureSearchingResponseDto.swift; sourceTree = "<group>"; };
CE1006562968230800FD31FB /* DepartureLocationModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DepartureLocationModel.swift; sourceTree = "<group>"; };
CE102C4729DB1D6B00E23E69 /* GetNewTokenResponseDto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GetNewTokenResponseDto.swift; sourceTree = "<group>"; };
CE102C4929DBAD3D00E23E69 /* AuthInterceptor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthInterceptor.swift; sourceTree = "<group>"; };
CE14676F296568DC00DCEA1B /* RunTrackingVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunTrackingVC.swift; sourceTree = "<group>"; };
CE14677729658C7200DCEA1B /* Stopwatch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Stopwatch.swift; sourceTree = "<group>"; };
CE1467792965A80700DCEA1B /* CustomBottomSheetVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomBottomSheetVC.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -283,6 +288,7 @@
CEC2A68F2962B06C00160BF7 /* convertLocationObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = convertLocationObject.swift; sourceTree = "<group>"; };
CEC2A6912962BE2900160BF7 /* DepartureSearchVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DepartureSearchVC.swift; sourceTree = "<group>"; };
CECA695B296E61D6002AF05C /* PrivateCourseNotUploadedResponseDto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrivateCourseNotUploadedResponseDto.swift; sourceTree = "<group>"; };
CEE59FD929DD6F7D00C791F1 /* Providers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Providers.swift; sourceTree = "<group>"; };
CEEC6B392961C4F300D00E1E /* CourseDrawingHomeVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CourseDrawingHomeVC.swift; sourceTree = "<group>"; };
CEEC6B3B2961C51A00D00E1E /* CourseStorageVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CourseStorageVC.swift; sourceTree = "<group>"; };
CEEC6B3D2961C53700D00E1E /* CourseDiscoveryVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CourseDiscoveryVC.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -373,6 +379,7 @@
isa = PBXGroup;
children = (
A3D1A77D29CF09B600DD54EC /* SignInResponseDto.swift */,
CE102C4729DB1D6B00E23E69 /* GetNewTokenResponseDto.swift */,
);
path = ResponseDto;
sourceTree = "<group>";
Expand Down Expand Up @@ -891,6 +898,8 @@
isa = PBXGroup;
children = (
CE6655BE295D82E200C64E12 /* .gitkeep */,
CE102C4929DBAD3D00E23E69 /* AuthInterceptor.swift */,
CEE59FD929DD6F7D00C791F1 /* Providers.swift */,
);
path = Service;
sourceTree = "<group>";
Expand Down Expand Up @@ -1313,6 +1322,7 @@
CE17F0382961BF8B00E1DED0 /* FontLiterals.swift in Sources */,
CE6655E8295D889600C64E12 /* UISwitch+.swift in Sources */,
CE0C23772966D64D00B45063 /* PageCVC.swift in Sources */,
CEE59FDA29DD6F7D00C791F1 /* Providers.swift in Sources */,
CE5875A029601500005D967E /* Toast.swift in Sources */,
CE40BB1E2968054F0030ABCA /* BaseResponse.swift in Sources */,
CE14677C2965C1B100DCEA1B /* RunningRecordVC.swift in Sources */,
Expand All @@ -1334,6 +1344,7 @@
CE6655FE295D912300C64E12 /* calculateTopInset.swift in Sources */,
CEEC6B492961C5E200D00E1E /* SplashVC.swift in Sources */,
CE6655D0295D85FF00C64E12 /* CancelBag.swift in Sources */,
CE102C4A29DBAD3D00E23E69 /* AuthInterceptor.swift in Sources */,
A3BC2F432966A93100198261 /* CourseDetailVC.swift in Sources */,
DAD5A3D8296C6D9600C8166B /* AdImageCollectionViewCell.swift in Sources */,
CE18E890296C76C100FEB569 /* RNLocationModel.swift in Sources */,
Expand Down Expand Up @@ -1391,6 +1402,7 @@
CE6655E6295D887F00C64E12 /* UIStackView+.swift in Sources */,
A3BC2F34296303A600198261 /* GoalRewardInfoCVC.swift in Sources */,
CEB8416E2962C45300BF8080 /* LocationSearchResultTVC.swift in Sources */,
CE102C4829DB1D6B00E23E69 /* GetNewTokenResponseDto.swift in Sources */,
CE6655CA295D84DD00C64E12 /* UserDefaultKeyList.swift in Sources */,
CE6655F2295D894D00C64E12 /* UIView+.swift in Sources */,
CE9291252965C9FB0010959C /* CourseDetailInfoView.swift in Sources */,
Expand Down
2 changes: 2 additions & 0 deletions Runnect-iOS/Runnect-iOS/Global/Literal/ImageLiterals.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ enum ImageLiterals {
static var imgSpaceship: UIImage { .load(named: "img_spaceship") }
static var imgAppIcon: UIImage { .load(named: "img_app_icon") }
static var imgAd: UIImage { .load(named: "img_ad") }
static var imgAppleLogin: UIImage { .load(named: "img_apple_login")}
static var imgKakaoLogin: UIImage { .load(named: "img_kakao_login")}
}

extension UIImage {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "Group 9514.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Group 9514@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Group 9514@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "Kakao Login.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Kakao Login@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Kakao Login@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 7 additions & 13 deletions Runnect-iOS/Runnect-iOS/Global/Utils/RNUtils/UserManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ enum RNError: Error {
final class UserManager {
static let shared = UserManager()

private var signInProvider = MoyaProvider<AuthRouter>(
plugins: [NetworkLoggerPlugin(verbose: true)]
)
private var authProvider = Providers.authProvider

@UserDefaultWrapper<String>(key: "accessToken") public var accessToken
@UserDefaultWrapper<String>(key: "refreshToken") public var refreshToken
Expand All @@ -35,7 +33,7 @@ final class UserManager {
}

func signIn(token: String, provider: String, completion: @escaping(Result<String, RNError>) -> Void) {
signInProvider.request(.signIn(token: token, provider: provider)) { [weak self] response in
authProvider.request(.signIn(token: token, provider: provider)) { [weak self] response in
guard let self = self else { return }
switch response {
case .success(let result):
Expand All @@ -47,7 +45,7 @@ final class UserManager {
self.accessToken = data.accessToken
self.refreshToken = data.refreshToken
self.isKakao = provider == "KAKAO" ? true : false
completion(.success(data.nickname ?? ""))
completion(.success(data.type)) // 로그인인지 회원가입인지 전달
} catch {
print(error.localizedDescription)
completion(.failure(.networkFail))
Expand All @@ -64,23 +62,19 @@ final class UserManager {
}
}

func autoSignIn(completion: @escaping(Result<String, RNError>) -> Void) {
guard let accessToken = self.accessToken else { return }
guard let isKakao = self.isKakao else { return }
let provider = isKakao ? "KAKAO" : "APPLE"
signInProvider.request(.signIn(token: accessToken, provider: provider)) { [weak self] response in
func getNewToken(completion: @escaping(Result<Bool, RNError>) -> Void) {
authProvider.request(.getNewToken) { [weak self] response in
guard let self = self else { return }
switch response {
case .success(let result):
let status = result.statusCode
if 200..<300 ~= status {
do {
let responseDto = try result.map(BaseResponse<SignInResponseDto>.self)
let responseDto = try result.map(BaseResponse<GetNewTokenResponseDto>.self)
guard let data = responseDto.data else { return }
self.accessToken = data.accessToken
self.refreshToken = data.refreshToken
self.isKakao = provider == "KAKAO" ? true : false
completion(.success(data.nickname ?? ""))
completion(.success(true))
} catch {
print(error.localizedDescription)
completion(.failure(.networkFail))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// GetNewTokenResponseDto.swift
// Runnect-iOS
//
// Created by sejin on 2023/04/03.
//

import Foundation

// MARK: - GetNewTokenResponseDto

struct GetNewTokenResponseDto: Codable {
let accessToken: String
let refreshToken: String
}
13 changes: 12 additions & 1 deletion Runnect-iOS/Runnect-iOS/Network/Router/AuthRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Moya

enum AuthRouter {
case signIn(token: String, provider: String)
case getNewToken
}

extension AuthRouter: TargetType {
Expand All @@ -26,27 +27,37 @@ extension AuthRouter: TargetType {
switch self {
case .signIn:
return "/auth"
case .getNewToken:
return "/auth/getNewToken"
}
}

var method: Moya.Method {
switch self {
case .signIn:
return .post
case .getNewToken:
return .get
}
}

var task: Moya.Task {
switch self {
case .signIn(let token, let provider):
return .requestParameters(parameters: ["token": token, "provider": provider], encoding: JSONEncoding.default)
case .getNewToken:
return .requestPlain
}
}

var headers: [String: String]? {
switch self {
case .signIn:
case .signIn, .getNewToken:
return Config.defaultHeader
}
}

var validationType: ValidationType {
return .successCodes
}
}
10 changes: 6 additions & 4 deletions Runnect-iOS/Runnect-iOS/Network/Router/CourseRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,13 @@ extension CourseRouter: TargetType {
var headers: [String: String]? {
switch self {
case .uploadCourseDrawing:
return ["Content-Type": "multipart/form-data",
"accessToken": Config.accessToken,
"refreshToken": Config.refreshToken]
return ["Content-Type": "multipart/form-data"]
default:
return Config.headerWithAccessToken
return Config.defaultHeader
}
}

var validationType: ValidationType {
return .successCodes
}
}
13 changes: 11 additions & 2 deletions Runnect-iOS/Runnect-iOS/Network/Router/PublicCourseRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import Foundation
import Moya

enum PublicCourseRouter {
case getCourseData
case getCourseSearchData(keyword: String)
Expand All @@ -16,12 +17,14 @@ enum PublicCourseRouter {
}

extension PublicCourseRouter: TargetType {

var baseURL: URL {
guard let url = URL(string: Config.baseURL) else {fatalError("baseURL could not be configured")
}
return url

}

var path: String {
switch self {
case .getCourseData, .courseUploadingData:
Expand All @@ -34,15 +37,16 @@ extension PublicCourseRouter: TargetType {
return "/public-course/user"
}
}

var method: Moya.Method {
switch self {
case .getCourseData, .getCourseSearchData, .getUploadedCourseDetail, .getUploadedCourseInfo:
return .get
case .courseUploadingData:
return .post
}

}

var task: Moya.Task {
switch self {
case .getCourseSearchData(let keyword):
Expand All @@ -56,10 +60,15 @@ extension PublicCourseRouter: TargetType {
return .requestPlain
}
}

var headers: [String: String]? {
switch self {
default:
return Config.headerWithAccessToken
return Config.defaultHeader
}
}

var validationType: ValidationType {
return .successCodes
}
}
6 changes: 5 additions & 1 deletion Runnect-iOS/Runnect-iOS/Network/Router/RecordRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ extension RecordRouter: TargetType {
var headers: [String: String]? {
switch self {
case .recordRunning, .getActivityRecordInfo:
return Config.headerWithAccessToken
return Config.defaultHeader
}
}

var validationType: ValidationType {
return .successCodes
}
}
6 changes: 5 additions & 1 deletion Runnect-iOS/Runnect-iOS/Network/Router/ScrapRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ extension ScrapRouter: TargetType {
var headers: [String: String]? {
switch self {
case .createAndDeleteScrap, .getScrapCourse:
return Config.headerWithAccessToken
return Config.defaultHeader
}
}

var validationType: ValidationType {
return .successCodes
}
}
8 changes: 6 additions & 2 deletions Runnect-iOS/Runnect-iOS/Network/Router/StampRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ extension StampRouter: TargetType {
var headers: [String: String]? {
switch self {
case .getGoalRewardInfo:
return Config.headerWithAccessToken
return Config.defaultHeader
}
}
}

var validationType: ValidationType {
return .successCodes
}
}
6 changes: 5 additions & 1 deletion Runnect-iOS/Runnect-iOS/Network/Router/UserRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ extension UserRouter: TargetType {
}

var headers: [String: String]? {
return Config.headerWithAccessToken
return Config.defaultHeader
}

var validationType: ValidationType {
return .successCodes
}
}
Loading