Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

상품 수정 시 비밀번호를 아는 이용자만 수정 화면으로 진입할 수 있도록 구성 #18

Closed
ryan-son opened this issue Sep 17, 2021 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@ryan-son
Copy link
Owner

  • 현재는 서버에 수정할 사항들과 함께 비밀번호를 PATCH 방식으로 요청하면 비밀번호가 맞고 틀림에 따라 성공, 실패가 정해져 권한을 가지지 않은 사용자가 게시물의 수정 기능에 접근할 수 있음.
  • 게시물 작성자가 접근했다고 하더라도 비밀번호를 모를 경우 반영되지 못할 수정 작업을 하는 등 불필요한 낭비가 이루어질 수 있음
@ryan-son ryan-son added the enhancement New feature or request label Sep 17, 2021
@ryan-son ryan-son self-assigned this Sep 17, 2021
@ryan-son
Copy link
Owner Author

상품 수정 시 비밀번호를 먼저 입력하고 수정화면으로 진입합니다. 올바르지 않은 비밀번호를 입력한 경우에는 재시도 또는 취소를 선택할 수 있습니다.

ezgif com-gif-maker (11)

구현

상품 수정을 위해서는 수정 사항과 함께 multipart/form-data 형식으로 password를 전송하여야 합니다. alert을 통해 password를 미리 입력 받아 서버에 PATCH 메서드를 통해 password 검증을 수행하여 password를 알지 못하면 수정화면으로 진입할 수 없도록하는 기능을 제공합니다.

func verifyPassword(
    itemID: Int,
    password: String,
    completion: @escaping ((Result<MarketItem, MarketItemDetailUseCaseError>) -> Void)
) {
    let path = EndPoint.item(id: itemID).path
    let marketItem = PatchMarketItem(title: nil, descriptions: nil, price: nil, currency: nil, stock: nil, discountedPrice: nil, images: nil, password: password)

    networkManager.multipartUpload(marketItem, to: path, method: .patch) { result in
        switch result {
        case .success(let data):
            do {
                let marketItem = try decoder.decode(MarketItem.self, from: data)
                completion(.success((marketItem)))
            } catch {
                completion(.failure(.unknown(error)))
            }
        case .failure(let error):
            completion(.failure(.networkError(error)))
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant