-
Notifications
You must be signed in to change notification settings - Fork 0
feat(ui, hooks): add sign in/out to the bible reader #102
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
Conversation
- add ability to sign in/out in the bible reader component - refactor the auth in the hooks package so that the user doesn't have to pass a redirectUri. We are now able to get a redirectUri from the provider. - add new icons for the settings and sign in/out feature in the reader.
🦋 Changeset detectedLatest commit: b57d5c4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Greptile SummaryThis PR adds sign in/out functionality to the bible reader component and refactors the authentication hooks to make Key Changes:
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant BibleReader
participant useYVAuth
participant AuthProvider
participant YouVersionAPI
Note over User,YouVersionAPI: Sign In Flow
User->>BibleReader: Click person icon
BibleReader->>BibleReader: Open popover
User->>BibleReader: Click Sign In button
BibleReader->>useYVAuth: Call signIn with no parameters
useYVAuth->>useYVAuth: Check if redirectUrl in params
alt redirectUrl provided
useYVAuth->>YouVersionAPI: signIn with provided value
else no redirectUrl
useYVAuth->>AuthProvider: Get redirectUri from context
alt redirectUri exists
useYVAuth->>YouVersionAPI: signIn with context value
else no redirectUri
useYVAuth-->>BibleReader: Throw error
end
end
YouVersionAPI-->>User: Redirect to OAuth flow
Note over User,YouVersionAPI: Post-Authentication
User->>AuthProvider: Return from OAuth
AuthProvider->>YouVersionAPI: handleAuthCallback
YouVersionAPI-->>AuthProvider: Return user data
AuthProvider->>AuthProvider: Update userInfo state
BibleReader->>useYVAuth: Get auth state
useYVAuth->>AuthProvider: Get userInfo from context
useYVAuth-->>BibleReader: Return auth and userInfo
BibleReader->>BibleReader: Display avatar or person icon
Note over User,YouVersionAPI: Sign Out Flow
User->>BibleReader: Click avatar
BibleReader->>BibleReader: Open popover
User->>BibleReader: Click Sign Out button
BibleReader->>useYVAuth: Call signOut
useYVAuth->>YouVersionAPI: clearAuthTokens
useYVAuth->>AuthProvider: setUserInfo to null
BibleReader->>BibleReader: Display person icon
|
cameronapak
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR looks good to me. I had one question. I'm gonna ask greptile a question, and then this should be good to go.
And, please do add a changeset!
|
@greptileai, can you help me understand a little more about packages/hooks/src/useYVAuth.test.tsx I saw there were two failed tests and want to understand more about why that might be happening. × should use redirectUri from provider when redirectUrl is not passed 213ms
× should use redirectUri from provider with scopes when redirectUrl is not passed 205ms |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on my analysis of the code and diff, I can now explain what's happening with the failing tests:
Analysis of the Failing Tests
The two failing tests are:
should use redirectUri from provider when redirectUrl is not passedshould use redirectUri from provider with scopes when redirectUrl is not passed
The Problem:
Looking at the test expectations, both tests expect YouVersionAPIUsers.signIn to be called with 'http://test.example.com', which suggests that's the redirectUri that should be provided by the test's auth provider configuration.
However, the tests are likely failing because:
-
Missing Test Setup: The
createAuthProviderWrapperfunction (which is imported but the file doesn't exist in the repository structure I can see) needs to provide aconfigwithredirectUri: 'http://test.example.com'to theYouVersionAuthProvider. -
Context Value Missing: From the changes in the diff, I can see that
redirectUriwas added to theAuthContextValueand is now being passed from the provider to the context. The test might be failing because the test wrapper isn't properly providing this value.
The Expected Flow:
- The
YouVersionAuthProviderreceives aconfigprop withredirectUri - It passes this to the context:
redirectUri: config.redirectUri - The
useYVAuthhook gets this from context:const { userInfo, setUserInfo, isLoading, error, redirectUri } = useYouVersionAuthContext(); - When
signIn()is called without parameters, it should useredirectUrias the fallback
The Fix:
The test is expecting the createAuthProviderWrapper to provide a configuration like:
const TestWrapper = createAuthProviderWrapper({
appKey: 'test-key',
redirectUri: 'http://test.example.com' // This is what the test expects
});But it seems like either:
- The
createAuthProviderWrapperfunction doesn't exist or isn't properly implemented - The wrapper isn't providing the correct
redirectUrivalue - There's an issue with how the
redirectUriis being passed through the context
To fix these tests, you would need to ensure that the test wrapper provides the expected redirectUri value in the configuration passed to YouVersionAuthProvider.
|
suggestion: Can you add photos of the new sign in and sign out UI? When I see a pull request that is a UI update, then it would help a lot to see the UI so that I don't have to pull it locally to review it |
5fc54f2 to
13e2eae
Compare
13e2eae to
0d16d1f
Compare
cameronapak
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
have to pass a redirectUri. We are now able to get a redirectUri
from the provider.
reader.
Light mode:

Dark mode:
