Skip to content

Commit

Permalink
feat: replaces auth token to supabase
Browse files Browse the repository at this point in the history
  • Loading branch information
abhibhaw committed Jun 22, 2024
1 parent 09e492f commit f25635f
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 21 deletions.
3 changes: 0 additions & 3 deletions milkton_executive/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
plugins {
id "com.android.application"
// START: FlutterFire Configuration
id 'com.google.gms.google-services'
// END: FlutterFire Configuration
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
}
Expand Down
3 changes: 0 additions & 3 deletions milkton_executive/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ pluginManagement {
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.0" apply false
// START: FlutterFire Configuration
id "com.google.gms.google-services" version "4.3.15" apply false
// END: FlutterFire Configuration
}

include ":app"
1 change: 0 additions & 1 deletion milkton_executive/firebase.json

This file was deleted.

7 changes: 0 additions & 7 deletions milkton_executive/ios/firebase_app_id_file.json

This file was deleted.

14 changes: 11 additions & 3 deletions milkton_executive/lib/cubit/auth/auth_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ final supabase = Supabase.instance.client;

class AuthCubit extends Cubit<AuthStates> {
AuthCubit() : super(AuthInitial()) {
User? currentUser = supabase.auth.currentUser;
final User? currentUser = supabase.auth.currentUser;
final Session? session = supabase.auth.currentSession;
if (currentUser != null) {
emit(AuthLoggedInState(currentUser: currentUser));
emit(AuthLoggedInState(
currentUser: currentUser,
currentSession: session!,
));
} else {
emit(AuthLoggedOutState());
}
Expand Down Expand Up @@ -40,7 +44,11 @@ class AuthCubit extends Cubit<AuthStates> {
phone: "+91$phoneNumber",
);
final User? currentUser = res.user;
emit(AuthLoggedInState(currentUser: currentUser!));
final Session? session = res.session;
emit(AuthLoggedInState(
currentUser: currentUser!,
currentSession: session!,
));
} catch (e) {
emit(AuthErrorState(error: e.toString()));
}
Expand Down
3 changes: 2 additions & 1 deletion milkton_executive/lib/cubit/auth/auth_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ final class AuthCodeVerifiedState extends AuthStates {}

final class AuthLoggedInState extends AuthStates {
final User currentUser;
AuthLoggedInState({required this.currentUser});
final Session currentSession;
AuthLoggedInState({required this.currentUser, required this.currentSession});
}

final class AuthLoggedOutState extends AuthStates {}
Expand Down
4 changes: 1 addition & 3 deletions milkton_executive/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ class MilktonExecutive extends StatelessWidget {
builder: (context, state) {
if (state is AuthLoggedInState) {
return GraphQLProvider(
client: getClient(
'TODO: token goes here', // Use the ID token here
),
client: getClient(state.currentSession.accessToken),
child: const HomeScreen(),
);
}
Expand Down

0 comments on commit f25635f

Please sign in to comment.