-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d57fbbe
commit c81872c
Showing
13 changed files
with
101 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 4 additions & 41 deletions
45
shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/AuthenticationService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,15 @@ | ||
package co.touchlab.droidcon.domain.service | ||
|
||
import co.touchlab.droidcon.UserContext | ||
import co.touchlab.droidcon.UserData | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import kotlinx.coroutines.flow.StateFlow | ||
import kotlinx.coroutines.flow.update | ||
import org.koin.core.component.KoinComponent | ||
import org.koin.core.component.inject | ||
|
||
abstract class AuthenticationService(isSignedIn: Boolean) : KoinComponent { | ||
private val userIdProvider: UserIdProvider by inject() | ||
|
||
private val _isAuthenticated = MutableStateFlow(isSignedIn) | ||
val isAuthenticated: StateFlow<Boolean> = _isAuthenticated | ||
|
||
abstract fun performGoogleLogin(): Boolean | ||
open fun performLogout(): Boolean { | ||
clearCredentials() | ||
return true | ||
} | ||
interface AuthenticationService { | ||
val isAuthenticated: StateFlow<Boolean> | ||
|
||
fun setCredentials( | ||
id: String, | ||
name: String?, | ||
email: String?, | ||
pictureUrl: String?, | ||
) { | ||
_isAuthenticated.update { true } | ||
userIdProvider.saveUserContext( | ||
UserContext( | ||
isAuthenticated = true, | ||
userData = UserData( | ||
id = id, | ||
name = name, | ||
email = email, | ||
pictureUrl = pictureUrl, | ||
) | ||
) | ||
) | ||
} | ||
|
||
fun clearCredentials() { | ||
_isAuthenticated.update { false } | ||
userIdProvider.saveUserContext( | ||
UserContext( | ||
isAuthenticated = false, | ||
userData = null | ||
) | ||
) | ||
} | ||
) | ||
fun clearCredentials() | ||
} |
6 changes: 6 additions & 0 deletions
6
shared/src/commonMain/kotlin/co/touchlab/droidcon/domain/service/GoogleSignInService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package co.touchlab.droidcon.domain.service | ||
|
||
interface GoogleSignInService { | ||
fun performGoogleLogin(): Boolean | ||
fun performGoogleLogout(): Boolean | ||
} |
Oops, something went wrong.