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

Unbreak wearos signin #294

Merged
merged 1 commit into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion wearApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ dependencies {
implementation(libs.androidx.compose.ui.tooling)
implementation(libs.wear.compose.navigation)
implementation(platform(libs.firebase.bom))
implementation(libs.firebase.auth.ktx)
implementation(libs.firebase.auth)
coreLibraryDesugaring(libs.desugar.jdk.libs)
debugImplementation(libs.compose.ui.tooling)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.viewModelScope
import com.google.android.gms.auth.api.signin.GoogleSignIn
import com.google.android.gms.auth.api.signin.GoogleSignInOptions
import com.google.firebase.auth.ktx.auth
import com.google.firebase.ktx.Firebase
import dev.gitlive.firebase.Firebase
import dev.gitlive.firebase.auth.auth
import fr.androidmakers.domain.interactor.GetAgendaUseCase
import fr.androidmakers.domain.interactor.GetFavoriteSessionsUseCase
import fr.androidmakers.domain.interactor.SyncBookmarksUseCase
Expand All @@ -17,7 +17,9 @@ import fr.androidmakers.domain.repo.UserRepository
import fr.paug.androidmakers.wear.applicationContext
import fr.paug.androidmakers.wear.data.LocalPreferencesRepository
import fr.paug.androidmakers.wear.ui.session.UISession
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
Expand Down Expand Up @@ -116,6 +118,7 @@ class MainViewModel(
}
}

@OptIn(DelicateCoroutinesApi::class)
fun signOut() {
val googleSignInClient = GoogleSignIn.getClient(
applicationContext,
Expand All @@ -125,7 +128,9 @@ class MainViewModel(
)
googleSignInClient.signOut()
googleSignInClient.revokeAccess()
Firebase.auth.signOut()
GlobalScope.launch {
Firebase.auth.signOut()
}
_user.value = null
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import com.google.android.gms.auth.api.signin.GoogleSignInAccount
import com.google.android.gms.auth.api.signin.GoogleSignInOptions
import com.google.android.horologist.auth.data.googlesignin.GoogleSignInEventListener
import com.google.android.horologist.auth.ui.googlesignin.signin.GoogleSignInViewModel
import com.google.firebase.Firebase
import com.google.firebase.auth.FirebaseAuthException
import com.google.firebase.auth.FirebaseUser
import com.google.firebase.auth.GoogleAuthProvider
import com.google.firebase.auth.auth
import dev.gitlive.firebase.Firebase
import dev.gitlive.firebase.auth.FirebaseAuthException
import dev.gitlive.firebase.auth.FirebaseUser
import dev.gitlive.firebase.auth.GoogleAuthProvider
import dev.gitlive.firebase.auth.auth
import fr.androidmakers.domain.model.User
import fr.androidmakers.domain.repo.UserRepository
import fr.paug.androidmakers.wear.R
Expand All @@ -36,8 +36,8 @@ class GoogleSignInViewModel(
Log.d(TAG, "Google sign in success")
val idToken = account.idToken
try {
val credential = GoogleAuthProvider.getCredential(idToken!!, null)
Firebase.auth.signInWithCredential(credential).await()
val credential = GoogleAuthProvider.credential(idToken!!, null)
Firebase.auth.signInWithCredential(credential)
UserData().userRepository.setUser(Firebase.auth.currentUser)
onSignInSuccess()
} catch (e: FirebaseAuthException) {
Expand All @@ -49,13 +49,6 @@ class GoogleSignInViewModel(
}
)

private suspend fun FirebaseUser.toUser(): User {
return User(
id = this.uid,
photoUrl = this.photoUrl.toString(),
)
}

class UserData: KoinComponent {
val userRepository: UserRepository by inject()
}
Loading