Conversation
Summary of ChangesHello @ally010314, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 이 Pull Request는 비회원 상태로 작성된 버블 데이터를 로그인한 사용자 계정에 연결하는 기능을 추가합니다. TokenManager를 사용하여 사용자 ID를 관리하고, DB 쿼리를 업데이트하여 기존 버블 데이터를 사용자 계정에 연결합니다. 이를 통해 사용자 경험을 향상시키고 데이터 일관성을 유지합니다. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
/gemini review |
There was a problem hiding this comment.
Code Review
This PR introduces a feature to link 'bubbles' created by non-members to their account upon member login, effectively managing bubbles per user by introducing user_id. While this is a significant step towards data isolation, two high-severity security issues were identified: a race condition in TokenManager that can lead to data being incorrectly attributed to the wrong user account during app startup, potentially causing cross-user data leakage, and SQL injection vulnerabilities in BaseLocalDataSourceImpl due to string concatenation in raw SQL queries. Additionally, I've provided specific review comments with suggestions for some code de-duplication and readability improvements. Addressing these security issues is critical for ensuring data integrity and user privacy, and incorporating the code suggestions will further enhance the quality of the codebase.
app/src/main/java/com/umc/edison/local/datasources/BubbleLocalDataSourceImpl.kt
Show resolved
Hide resolved
app/src/main/java/com/umc/edison/local/datasources/BubbleLocalDataSourceImpl.kt
Show resolved
Hide resolved
app/src/main/java/com/umc/edison/data/repository/BubbleRepositoryImpl.kt
Show resolved
Hide resolved
app/src/main/java/com/umc/edison/local/datasources/BubbleLocalDataSourceImpl.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Code Review
버블 계정 관리 기능 구현을 위한 변경 사항을 검토했습니다. user_id 컬럼 추가, TokenManager에 사용자 ID 관리 기능 추가, 그리고 BubbleLocalDataSource 및 BubbleRepository에서 사용자 ID를 활용하여 버블을 저장하고 조회하는 로직이 잘 반영되었습니다. 특히 게스트 버블을 로그인한 사용자에게 연결하는 기능은 사용자 경험을 크게 향상시킬 것으로 보입니다. 전반적으로 기능 구현은 잘 되었으나, 몇 가지 개선 사항이 발견되어 코멘트를 남깁니다.
A계정으로 버블 작성 -> 로그아웃 -> TokenManager에 저장된 ID가 없으므로 null을 반환하고 DB에 user_id = null로 저장합니다. A계정으로 작성된 버블이 보이지 않음 (null인 버블만 보이게됨)
B 계정 로그인 -> 로그인 성공 시: UserRepository에서 구글 로그인/회원가입 후 TokenManager에 이메일(userId)을 저장합니다. (user를 유일하게 식별할 수 있으면 되는 거라 이메일도 괜찮다고 생각했어요)
직후 bubbleRepository.linkGuestBubblesToUser를 호출하여 DB에서 user_id가 NULL인 모든 버블을 찾아 방금 로그인한 이메일로 업데이트합니다
BubbleLocal
user_id 컬럼 추가
TokenManager
userId (이메일)를 저장(saveUserId), 로드(loadUserId), 조회(getUserId)하는 기능 추가
BubbleLocalDataSource & Impl
addBubble 함수: userId 파라미터를 받아 저장 시점에 주입하도록 수정했습니다.
(BubbleEntity를 수정하면 수정 사항이 복잡해져서 건드리지 않고
addBubble 함수 내부에서 BubbleLocal 객체를 직접 생성하도록 구현했습니다.)
linkGuestBubblesToUser 함수: UPDATE bubbles SET user_id = ? WHERE user_id IS NULL 쿼리 실행 구현했습니다
BubbleRepositoryImpl
TokenManager를 주입받아 addBubble 시 tokenManager.getUserId()를 호출해 현재 상태(회원/비회원)에 따라 ID를 넘기도록 했습니다
UserRepositoryImpl
BubbleRepository를 주입받아 로그인/회원가입 성공 직후 linkGuestBubblesToUser 호출하도록 했습니다.