-
Notifications
You must be signed in to change notification settings - Fork 2
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
Define Model for Supabase authentication #25
Conversation
Changed the app name from SampleApp to PeriodPals and cascaded the change throughout. Added basic dependencies as well as Supabase dependencies.
Updated Kotlin version from 1.9.0 to 2.0.0-RC1 for compatibility with kotlinx.serialization.Serializable.
`ExampleRobolectricTest` was acting up because of a reference to a useless second activity that was deleted. Kept the commented out code as example.
Created interface `com.android.periodpals.model.auth.AuthModel`. For now, it has three functions: `login`, `register` and `logout`. They can be called from the View Model with an email and a password (except `logout` which does not take arguments).
Created class `com.android.periodpals.model.auth.AuthModelSupabase`, implementing interface `AuthModel`. It overrides every function from its interface.
Changed the functions' signatures in `AuthModel` and `AuthModelSupabase`.
…ct `onFailure` signature Added `isUserLoggedIn` function in `AuthModel`. Changed the `onFailure` lambdas' signature to take an `Exception` as argument instead of an `Error`.
…k if user logged in method Surrounded calls on Supabase client with `try-catch` and use newly added `onSuccess` and `onFailure` lambdas. Implemented `isUserLoggedIn` function to check whether or not the user is logged in. Takes into account session timeout.
… purposes The `SupabaseClient` was impossible to mock because of the dependencies coming from the plugins. Therefore, I added a wrapper to the Supabase `PluginManager` that for now is only useful for the `Auth` plugin. Also implemented its use in `AuthModelSupabase`.
For now, `register success`, `login success` and `isUserLoggedIn success` do not work because of mocking issues.
Used the mocking functions properly on call to `signUpWith`.
Changed the argument matcher for a nullable argument from `any` to `anyOrNull`.
Used the mocking functions properly on call to `signInWith`.
Deleted problematic `ExampleInstrumentedTest.kt` and `ExampleRobolectricTest.kt` as they were imported from the Sample App we started from.
…iodpals into feat/authentication/model # Conflicts: # app/src/main/java/com/android/periodpals/MainActivity.kt
…hentication/model # Conflicts: # gradle/libs.versions.toml
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.
Cool stuff
- Amazing tests! I like the structure of the tests, checking whether each function of the Model works as expected both in successful and unsuccessful scenarios.
- Code runs locally
Improvements
- Adding some comments to the code would imporve readability and improve the review process :3
Steps before merge
LGTM
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.
Very nice work!
Comments
- Besides, changing the error messages for Log.e I think there is no further improvements at this stage
- Very clean implementation: PluginManagerWrapper
- Excellent tests using Mockito
Improvements
- Changing the return type of the function
isUserLoggedIn
to boolean?
Steps before merge
LGTM
Log.d(TAG, "register: successfully registered the user") | ||
onSuccess() | ||
} catch (e: Exception) { | ||
Log.d(TAG, "register: failed to register the user: ${e.message}") |
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.
Nitpick
: use Log.e for errors for better readability of the logs. Check documentation
app/src/main/java/com/android/periodpals/model/auth/AuthModelSupabase.kt
Show resolved
Hide resolved
…hentication/model # Conflicts: # app/build.gradle.kts
Define Model for Supabase authentication
Description:
This PR introduces new features related to authentication, along with corresponding unit tests.
Key Changes:
Authentication Model:
AuthModel.kt
for handling authentication processes. This file includes logic for user authentication, token management, and user session handling.AuthModelSupabase.kt
to integrate with Supabase's backend services.Plugin Manager wrapper:
SupabaseClient.pluginManager
for testing purposes. This does not change the behavior, just allows mocking on the client.Unit Tests:
Created unit tests to verify the functionality of the authentication model and plugin manager:
Improvements:
We could implement authentication via a third party like Google.