Skip to content

Commit

Permalink
Attempt to fix Google sign-in user switch (#330)
Browse files Browse the repository at this point in the history
Co-authored-by: Walter Lara <[email protected]>
  • Loading branch information
wlara and Walter Lara authored Oct 3, 2024
1 parent b60c355 commit e71b1c6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
5 changes: 4 additions & 1 deletion android/app-newm/src/main/java/io/newm/Logout.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package io.newm

import android.content.Context
import com.google.android.gms.auth.api.signin.GoogleSignInClient
import com.jakewharton.processphoenix.ProcessPhoenix
import io.newm.shared.NewmAppLogger
import io.newm.shared.public.usecases.LoginUseCase
Expand All @@ -17,13 +18,15 @@ class Logout(
private val userSessionUseCase: UserSessionUseCase,
private val restartApp: RestartApp,
private val scope: CoroutineScope,
private val logger: NewmAppLogger
private val logger: NewmAppLogger,
private val googleSignInClient: GoogleSignInClient
) {

fun signOutUser() {
scope.launch {
try {
loginUseCase.logout()
googleSignInClient.signOut()
logger.info("Logout", "Logout successful")
restartApp.run()
} catch (e: Exception) {
Expand Down
22 changes: 10 additions & 12 deletions android/app-newm/src/main/java/io/newm/di/android/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,18 @@ val viewModule = module {
get()
, get())
}
single<GoogleSignInLauncher> {
single {
val sharedBuildConfig = get<NewmSharedBuildConfig>()

GoogleSignInLauncherImpl(
GoogleSignIn.getClient(
androidContext(),
GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(sharedBuildConfig.googleAuthClientId)
.requestScopes(Scope(Scopes.EMAIL), Scope(Scopes.PROFILE))
.requestEmail()
.build()
)
GoogleSignIn.getClient(
androidContext(),
GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(sharedBuildConfig.googleAuthClientId)
.requestScopes(Scope(Scopes.EMAIL), Scope(Scopes.PROFILE))
.requestEmail()
.build()
)
}
single<GoogleSignInLauncher> { GoogleSignInLauncherImpl(get()) }
factory { params ->
WelcomeScreenPresenter(
navigator = params.get(),
Expand Down Expand Up @@ -109,6 +107,6 @@ val viewModule = module {
}

val androidModules = module {
single { Logout(get(), get(), get(), get(), get()) }
single { Logout(get(), get(), get(), get(), get(), get()) }
single { RestartApp(get()) }
}

0 comments on commit e71b1c6

Please sign in to comment.