Skip to content

[Feat-T3-67] Apple 로그인 구현#14

Merged
choijungp merged 12 commits intodevelopfrom
feat/apple-login
Jul 3, 2025
Merged

[Feat-T3-67] Apple 로그인 구현#14
choijungp merged 12 commits intodevelopfrom
feat/apple-login

Conversation

@choijungp
Copy link
Copy Markdown
Contributor

🌁 Background

소셜 로그인 중 애플 로그인 기능을 구현하였습니다.
AuthenticationServices 프레임워크를 추가하여 Apple 로그인을 진행하였습니다.

📱 Screenshot

Simulator.Screen.Recording.-.iPhone.15.-.2025-07-02.at.14.39.11.mp4
스크린샷 2025-07-02 14 42 38

👩‍💻 Contents

  • LoginViewController에 apple 로그인 버튼 추가
  • LoginUseCase, AuthRepository에 appleLogin 기능 추가
  • AuthError 세분화

✅ Testing

이전 카카오 로그인 PR에서 구현한 LoginViewController에 애플 로그인 버튼을 추가하여 테스트를 진행하였습니다.
카카오 로그인과 마찬가지로 Keychain에 서버로부터 받은 토큰 값을 저장한 것까지 테스트 완료하였습니다.

📝 Review Note

Apple 로그인 닉네임

  • Apple 로그인은 최초 로그인 시에만 닉네임 정보를 가져옵니다.
  • 따라서 애플 로그인 시도 시에 닉네임을 가져왔다면 UserDefaults에 닉네임을 저장하고, 다음 로그인 시도부터 닉네임이 없을 때 저장된 값을 불러와 서버 통신을 시도합니다.
  • 그에 따라 AuthRepository에 UserDefaults 의존성을 추가하였습니다.

LoginViewController에서 Apple authToken 및 닉네임 가져오기

  • Apple 로그인을 구현할 때 ASAuthorizationControllerDelegate, ASAuthorizationControllerPresentationContextProviding를 채택해서 내부 메서드를 구현해주어야 authToken과 원하는 유저 정보를 가져올 수 있습니다.
  • ASAuthorizationControllerDelegate은 인증 흐름이 완료되었을 때 성공 및 실패를 받아 처리하는 역할을 하고,
  • ASAuthorizationControllerPresentationContextProviding은 인증 UI를 어디서 표시할지 알려주는 역할을 합니다.
  • 이때 ASAuthorizationControllerPresentationContextProviding은 UIWindow를 필요로 하고, Repository 단에서 view.window를 접근하기에는 어려움이 있었습니다.
// MARK: - ASAuthorizationControllerPresentationContextProviding
extension LoginViewController: ASAuthorizationControllerPresentationContextProviding {
    public func presentationAnchor(for controller: ASAuthorizationController) -> ASPresentationAnchor {
        return view.window ?? UIWindow()
    }
}
  • 따라서 LoginViewController에 해당 프로토콜들을 채택하고 Apple 인증 성공 시 닉네임, 토큰 값을 전달받아 이후 Repository에서는 서버 통신만을 할 수 있도록 구현하였습니다.
  • 만약 더 좋은 방법이 있다면 알려주세요 ~!

📣 Related Issue

  • close #T3-67

choijungp added 10 commits July 1, 2025 13:37
- ASAuthorizationControllerDelegate, ASAuthorizationControllerPresentationContextProviding 채택해주는 로직 LoginViewController로 이동 (기존 AuthRepository)
- LoginViewModel에서 apple 로그인 결과에 따라 값을 방출할 수 있도록 구현
- LoginUseCaseProtocol, LoginUseCase appleLogin 함수 정의 및 구현
- AuthRepositoryProtocol, AuthRepository appleLogin 정의 및 구현
- 받은 닉네임, 토큰 값을 통해 서버 통신 로직 구현
- UserDefaults에 닉네임 저장 및 불러오는 로직 구현
@choijungp choijungp requested a review from generalban July 2, 2025 06:09
@choijungp choijungp self-assigned this Jul 2, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jul 2, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing Touches
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Post Copyable Unit Tests in a Comment
  • Commit Unit Tests in branch feat/apple-login

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary or @coderabbitai 요약 to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@generalban generalban left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오탈자 체크만 해주시면 됩니닷~ 고생하셨어요

static let loginBottomPadding: CGFloat = 54
private enum Layout {
static let horizontalMargin: CGFloat = 20
static let loginButtonHegiht: CGFloat = 54
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

사소한 타이포~ Hegiht → Height 오타 수정해주세요

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apple 로그인 구현 수고 많으셨습니다! 사소한 오타(loginButtonHegiht)만 수정해주시면 바로 Approve 드리겠습니다 :)

try self.saveNickname(nickname: nickname)
savedNickname = nickname
} else {
savedNickname = try self.loadNickname()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그냥 의견일뿐입니다! 수정할거 없습니다! if let + else에서 nickname 값을 한 번 더 리턴하지 않도록 guard let을 써서 early exit 방식도 가능합니닷

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵 ~ 최초 로그인 시에만 닉네임을 저장하고 불러온 닉네임이라면 저장할 필요가 없으니까 if - else를 사용하긴 했습니다.

@choijungp choijungp merged commit a9d19eb into develop Jul 3, 2025
2 checks passed
@choijungp choijungp deleted the feat/apple-login branch July 3, 2025 05:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants