Skip to content

Commit

Permalink
✨ Feat: #40 - 비밀번호 변경 수정 완료 (화면전환 수정 필요) (#42)
Browse files Browse the repository at this point in the history
* ✨ Feat: #40 - 비밀번호 찾기 SendCertifyCode API 연결

* ✨ Feat: #40 - SendCertifyCode API 연결 및 UI연동

* ✨ Feat: #40 - confirmCertifyCode, reSettingPassword API 로직 작성

* ✨ Feat: #40 - 재전송 버튼 누를 시, sendCertifyCode 재호출 및 타이머 초기화

* ✨ Feat: #40 - confirmCertifyCode API -> UI바인딩 완료

* 📝 Clore: path 변경내용 적용

* ✨ Feat: #40 - 비밀번호 변경 완 (화면 전환 로직 수정 필요,,,)

* conflict fix -> 체리픽
  • Loading branch information
usa4060 authored Nov 25, 2023
1 parent 2aad4d8 commit 775247b
Show file tree
Hide file tree
Showing 27 changed files with 565 additions and 166 deletions.
2 changes: 1 addition & 1 deletion CMC/Sources/App/AppCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class AppCoordinator: CoordinatorType {
)
)
)
self.pushViewController(viewController: splashViewController)
self.navigationController.pushViewController(splashViewController, animated: false)
}
}

Expand Down
21 changes: 21 additions & 0 deletions CMC/Sources/Data/DTO/Auth/ConfirmCertifyCodeDTO.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// ConfirmCertifyCodeDTO.swift
// CMC
//
// Created by Siri on 11/25/23.
// Copyright © 2023 com.softsquared.cmc. All rights reserved.
//

// MARK: - ConfirmCertifyCodeDTO
struct ConfirmCertifyCodeDTO: Codable {
let isSuccess: Bool
let code: String
let message: String
let result: String

func toDomain() -> ConfirmCertifyCodeModel {
return ConfirmCertifyCodeModel(
message: result
)
}
}
21 changes: 21 additions & 0 deletions CMC/Sources/Data/DTO/Auth/ResettingPasswordDTO.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// ResettingPasswordDTO.swift
// CMC
//
// Created by Siri on 11/25/23.
// Copyright © 2023 com.softsquared.cmc. All rights reserved.
//

// MARK: - RessetingPasswordDTO
struct ResettingPasswordDTO: Codable {
let isSuccess: Bool
let code: String
let message: String
let result: String

func toDomain() -> ResettingPasswordModel {
return ResettingPasswordModel(
message: result
)
}
}
23 changes: 23 additions & 0 deletions CMC/Sources/Data/DTO/Auth/SendCertifyCodeDTO.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// SendCertifyCodeDTO.swift
// CMC
//
// Created by Siri on 11/25/23.
// Copyright © 2023 com.softsquared.cmc. All rights reserved.
//

import Foundation

// MARK: - SendCertifyCodeDTO
struct SendCertifyCodeDTO: Codable {
let isSuccess: Bool
let code: String
let message: String
let result: String

func toDomain() -> SendCertifyCodeModel {
return SendCertifyCodeModel(
message: result
)
}
}
23 changes: 19 additions & 4 deletions CMC/Sources/Data/Endpoint/AuthEndpoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,22 @@ enum AuthEndpoint: Endpoint {
case signIn(body: SignInBody)
case signUp(body: SignUpBody)
case emailDup(query: EmailDupQuery)
case sendCertifyCode(query: SendCertifyCodeQuery)
case confirmCertifyCode(body: ConfirmCertifyCodeBody)
case resettingPassword(body: ResettingPasswordBody)

var baseURL: URL? {
return URL(string: Xcconfig.BASE_URL + "/auth")
}

var method: HTTPMethod {
switch self {
case .signUp, .signIn:
case .signUp, .signIn, .confirmCertifyCode:
return .POST
case .emailDup:
case .emailDup, .sendCertifyCode:
return .GET
case .resettingPassword:
return .PATCH
}
}

Expand All @@ -37,11 +42,13 @@ enum AuthEndpoint: Endpoint {
var path: String {
switch self {
case .signUp:
return "/signUp"
return "/sign-up"
case .signIn:
return "/signIn"
return "/log-in"
case .emailDup:
return "/email"
case .sendCertifyCode, .confirmCertifyCode, .resettingPassword:
return "/password"
}

}
Expand All @@ -56,6 +63,14 @@ enum AuthEndpoint: Endpoint {
return .query([
"email": query.email
])
case .sendCertifyCode(let query):
return .query([
"email": query.email
])
case .confirmCertifyCode(let body):
return .body(body)
case .resettingPassword(let body):
return .body(body)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// ConfirmCertifyCodeBody.swift
// CMC
//
// Created by Siri on 11/25/23.
// Copyright © 2023 com.softsquared.cmc. All rights reserved.
//

import Foundation

// MARK: - ConfirmCertifyCodeBody
struct ConfirmCertifyCodeBody: Codable {
let email: String
let code: String
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// ResettingPasswordBody.swift
// CMC
//
// Created by Siri on 11/25/23.
// Copyright © 2023 com.softsquared.cmc. All rights reserved.
//

import Foundation

// MARK: - ResettingPasswordBody
struct ResettingPasswordBody: Codable {
let email: String
let password: String
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// SendCertifyCodeQuery.swift
// CMC
//
// Created by Siri on 11/25/23.
// Copyright © 2023 com.softsquared.cmc. All rights reserved.
//

import Foundation

// MARK: - SendCertifyCodeQuery
struct SendCertifyCodeQuery: Codable {
let email: String
}
2 changes: 1 addition & 1 deletion CMC/Sources/Data/NetworkService/Endpoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

enum HTTPMethod: String {
case GET, POST, DELETE, FETCH
case GET, POST, DELETE, PATCH
}

typealias HTTPHeaders = [String: String]
Expand Down
34 changes: 34 additions & 0 deletions CMC/Sources/Data/Repositories/Auth/DefaultAuthRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,38 @@ final class DefaultAuthRepository: AuthRepository {
}
}

func sendCertifyCode(query: SendCertifyCodeQuery) -> Single<SendCertifyCodeDTO> {
let endpoint = AuthEndpoint.sendCertifyCode(query: query)
return networkService.request(endpoint)
.flatMap { data in
guard let dto = Utility.decode(SendCertifyCodeDTO.self, from: data) else {
return Single.error(NetworkError.decodingFailed)
}
return Single.just(dto)
}
}

func confirmCertifyCode(body: ConfirmCertifyCodeBody) -> Single<ConfirmCertifyCodeDTO> {
let endpoint = AuthEndpoint.confirmCertifyCode(body: body)
return networkService.request(endpoint)
.flatMap { data in
guard let dto = Utility.decode(ConfirmCertifyCodeDTO.self, from: data) else {
return Single.error(NetworkError.decodingFailed)
}
return Single.just(dto)
}
}

func reSettingPassword(body: ResettingPasswordBody) -> Single<ResettingPasswordDTO> {
let endpoint = AuthEndpoint.resettingPassword(body: body)
return networkService.request(endpoint)
.flatMap { data in
guard let dto = Utility.decode(ResettingPasswordDTO.self, from: data) else {
return Single.error(NetworkError.decodingFailed)
}
return Single.just(dto)
}
}


}
29 changes: 29 additions & 0 deletions CMC/Sources/Data/Repositories/Auth/FakeAuthRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,34 @@ final class FakeAuthRepository: AuthRepository {
)
return Single.just(fakeEmailDupDTO)
}

func sendCertifyCode(query: SendCertifyCodeQuery) -> Single<SendCertifyCodeDTO> {
let fakeSendCertifyCodeDTO = SendCertifyCodeDTO(
isSuccess: true,
code: "200",
message: "성공",
result: "인증번호가 발송되었습니다."
)
return Single.just(fakeSendCertifyCodeDTO)
}

func confirmCertifyCode(body: ConfirmCertifyCodeBody) -> Single<ConfirmCertifyCodeDTO> {
let fakeConfirmCertifyCodeDTO = ConfirmCertifyCodeDTO(
isSuccess: true,
code: "200",
message: "성공",
result: "인증번호가 발송되었습니다."
)
return Single.just(fakeConfirmCertifyCodeDTO)
}

func reSettingPassword(body: ResettingPasswordBody) -> Single<ResettingPasswordDTO> {
let fakeResettingPasswordDTO = ResettingPasswordDTO(
isSuccess: true,
code: "200",
message: "성공",
result: "인증번호가 발송되었습니다."
)
return Single.just(fakeResettingPasswordDTO)
}
}
14 changes: 14 additions & 0 deletions CMC/Sources/Domain/Models/Auth/ConfirmCertifyCodeModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// ConfirmCertifyCodeModel.swift
// CMC
//
// Created by Siri on 11/25/23.
// Copyright © 2023 com.softsquared.cmc. All rights reserved.
//

import Foundation

// MARK: - ConfirmCertifyCodeModel
struct ConfirmCertifyCodeModel: Codable {
let message: String
}
14 changes: 14 additions & 0 deletions CMC/Sources/Domain/Models/Auth/ResettingPasswordModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// ResettingPasswordModel.swift
// CMC
//
// Created by Siri on 11/25/23.
// Copyright © 2023 com.softsquared.cmc. All rights reserved.
//

import Foundation

// MARK: - ResettingPasswordModel
struct ResettingPasswordModel: Codable {
let message: String
}
14 changes: 14 additions & 0 deletions CMC/Sources/Domain/Models/Auth/SendCertifyCodeModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// SendCertifyCodeModel.swift
// CMC
//
// Created by Siri on 11/25/23.
// Copyright © 2023 com.softsquared.cmc. All rights reserved.
//

import Foundation

// MARK: - SendCertifyCodeModel
struct SendCertifyCodeModel: Codable {
let message: String
}
3 changes: 3 additions & 0 deletions CMC/Sources/Domain/Repositories/Auth/AuthRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ protocol AuthRepository {
func signUp(body: SignUpBody) -> Single<SignUpDTO>
func signIn(body: SignInBody) -> Single<SignInDTO>
func emailDup(query: EmailDupQuery) -> Single<EmailDupDTO>
func sendCertifyCode(query: SendCertifyCodeQuery) -> Single<SendCertifyCodeDTO>
func confirmCertifyCode(body: ConfirmCertifyCodeBody) -> Single<ConfirmCertifyCodeDTO>
func reSettingPassword(body: ResettingPasswordBody) -> Single<ResettingPasswordDTO>
}
3 changes: 3 additions & 0 deletions CMC/Sources/Domain/Usecases/Auth/AuthUsecase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ protocol AuthUsecase {
func signUp(body: SignUpBody) -> Single<SignUpModel>
func signIn(body: SignInBody) -> Single<SignInModel>
func emailDup(query: EmailDupQuery) -> Single<EmailDupModel>
func sendCertifyCode(query: SendCertifyCodeQuery) -> Single<SendCertifyCodeModel>
func confirmCertifyCode(body: ConfirmCertifyCodeBody) -> Single<ConfirmCertifyCodeModel>
func reSettingPassword(body: ResettingPasswordBody) -> Single<ResettingPasswordModel>
}
21 changes: 20 additions & 1 deletion CMC/Sources/Domain/Usecases/Auth/DefaultAuthUsecase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,30 @@ final class DefaultAuthUsecase: AuthUsecase {
}

func emailDup(query: EmailDupQuery) -> Single<EmailDupModel> {

return authRepository.emailDup(query: query)
.map { dto in
return dto.toDomain()
}
}

func sendCertifyCode(query: SendCertifyCodeQuery) -> Single<SendCertifyCodeModel> {
return authRepository.sendCertifyCode(query: query)
.map { dto in
return dto.toDomain()
}
}

func confirmCertifyCode(body: ConfirmCertifyCodeBody) -> Single<ConfirmCertifyCodeModel> {
return authRepository.confirmCertifyCode(body: body)
.map { dto in
return dto.toDomain()
}
}

func reSettingPassword(body: ResettingPasswordBody) -> Single<ResettingPasswordModel> {
return authRepository.reSettingPassword(body: body)
.map { dto in
return dto.toDomain()
}
}
}
Loading

0 comments on commit 775247b

Please sign in to comment.