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

🐛 Supabase のセッション保存・復元処理を自前で実装 #111

Merged
merged 1 commit into from
Dec 4, 2023

Conversation

tatsutakein
Copy link
Member

@tatsutakein tatsutakein commented Dec 4, 2023

Issue

  • close #ISSUE_NUMBER 🦕

概要

expiresAt が正しく復元されずリフレッシュが動作しない状態だったため、Supabase のセッション保存・復元処理を自前で実装します。

レビュー観点

特になし

レビューレベル

  • Lv0: まったく見ないで Approve する
  • Lv1: ぱっとみて違和感がないかチェックして Approve する
  • Lv2: 仕様レベルまで理解して、仕様通りに動くかある程度検証して Approve する
  • Lv3: 実際に環境で動作確認したうえで Approve する

レビュー優先度

  • すぐに見てもらいたい ( hotfix など ) 🚀
  • 今日中に見てもらいたい 🚗
  • 今日〜明日中で見てもらいたい 🚶
  • 数日以内で見てもらいたい 🐢

参考リンク

スクリーンショット

Before After

Summary by CodeRabbit

  • 新機能
    • マルチプラットフォーム設定とコルーチンに関連する機能がプロジェクトに統合されました。
    • Supabaseクライアント作成時にセッションマネージャーを含むように変更されました。
    • ユーザーセッションを管理するための新しいNitoSettingsSessionManagerクラスが追加されました。

@tatsutakein tatsutakein requested a review from a team as a code owner December 4, 2023 11:18
Copy link

coderabbitai bot commented Dec 4, 2023

Walkthrough

Kotlinプロジェクトにおいて、マルチプラットフォーム設定とコルーチンに関連する機能が追加されました。具体的には、依存関係にmultiplatformSettingsNoArgmultiplatformSettingsCoroutinesが導入され、Supabaseクライアントの生成関数がセッションマネージャーを含むように変更され、新しいNitoSettingsSessionManagerクラスが追加されています。

Changes

ファイル 変更概要
core/network/build.gradle.kts multiplatformSettingsNoArgmultiplatformSettingsCoroutinesの実装が追加された。
.../network/SupabaseClient.kt createNitoSupabaseClient関数が変更され、NitoSettingsSessionManagerクラスが新たに追加された。

🐰🌟
コードの森を跳ねるうさぎ、
新しい葉を見つけては喜び。
セッション管理、繋がりを編む、
マルチプラットフォームの夢を紡ぐ。


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 1801fe3 and 0e1a7ee.
Files selected for processing (2)
  • core/network/build.gradle.kts (1 hunks)
  • core/network/src/commonMain/kotlin/club/nito/core/network/SupabaseClient.kt (2 hunks)
Files skipped from review due to trivial changes (1)
  • core/network/build.gradle.kts
Additional comments: 2
core/network/src/commonMain/kotlin/club/nito/core/network/SupabaseClient.kt (2)
  • 39-39: NitoSettingsSessionManager クラスは private として宣言されていますが、これはこのクラスがファイル内でのみ使用されることを意味します。他の場所でこのクラスが必要な場合は、アクセス修飾子を適切に変更する必要があります。

  • 40-40: ExperimentalSettingsApi への OptIn は、APIがまだ実験的であることを示しています。将来的にAPIが変更される可能性があるため、このAPIに依存するコードは注意して使用する必要があります。

@@ -15,8 +23,43 @@ internal fun createNitoSupabaseClient(
supabaseKey = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imd0Zmp1a3JhdXlocmJnbHJ6bHZhIiwicm9sZSI6ImFub24iLCJpYXQiOjE2OTkwMDQ3NTgsImV4cCI6MjAxNDU4MDc1OH0.zRjlzXVyz4vBM8Tb8GcpyPyTkCmOwdV-Xs18Agw2w-E",
Copy link

Choose a reason for hiding this comment

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

ハードコードされた supabaseKey はセキュリティリスクを引き起こす可能性があります。これが実際のキーである場合、環境変数や設定ファイルから読み込むように変更することを検討してください。

Comment on lines +44 to +45
override suspend fun saveSession(session: UserSession) {
suspendSettings.putString(SETTINGS_KEY, nitoJsonSettings.encodeToString(session))
Copy link

Choose a reason for hiding this comment

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

saveSession メソッドにはエラーハンドリングがありません。putString 操作が失敗した場合に備えて、エラーハンドリングを追加することを検討してください。

@OptIn(ExperimentalSettingsApi::class)
override suspend fun saveSession(session: UserSession) {
    try {
        suspendSettings.putString(SETTINGS_KEY, nitoJsonSettings.encodeToString(session))
    } catch (e: Exception) {
        Logger.e(e) { "Failed to save session" }
    }
}

@tatsutakein tatsutakein merged commit 3f2ea9b into main Dec 4, 2023
4 checks passed
@tatsutakein tatsutakein deleted the rt/fix-session-manager branch December 4, 2023 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant