-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/dev' into feature/mod-board-piece
- Loading branch information
Showing
23 changed files
with
348 additions
and
108 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
30 changes: 30 additions & 0 deletions
30
...uth/src/main/java/com/goalpanzi/mission_mate/core/data/auth/AuthTokenExpirationHandler.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,30 @@ | ||
package com.goalpanzi.mission_mate.core.data.auth | ||
|
||
import com.goalpanzi.mission_mate.core.datastore.datasource.AuthDataSource | ||
import com.goalpanzi.mission_mate.core.datastore.datasource.DefaultDataSource | ||
import com.goalpanzi.mission_mate.core.datastore.datasource.MissionDataSource | ||
import com.goalpanzi.mission_mate.core.navigation.NavigationEventHandler | ||
import com.goalpanzi.mission_mate.core.navigation.di.AuthNavigation | ||
import com.goalpanzi.mission_mate.core.network.TokenExpirationHandler | ||
import kotlinx.coroutines.flow.collect | ||
import javax.inject.Inject | ||
|
||
class AuthTokenExpirationHandler @Inject constructor( | ||
private val authDataSource: AuthDataSource, | ||
private val defaultDataSource: DefaultDataSource, | ||
private val missionDataSource: MissionDataSource, | ||
@AuthNavigation private val authNavigationEventHandler: NavigationEventHandler | ||
) : TokenExpirationHandler { | ||
|
||
override suspend fun handleRefreshTokenExpiration() { | ||
clearCachedData() | ||
authNavigationEventHandler.triggerRouteToNavigate("RouteModel.Login") | ||
} | ||
|
||
private suspend fun clearCachedData(){ | ||
authDataSource.setAccessToken("") | ||
authDataSource.setRefreshToken("") | ||
defaultDataSource.clearUserData().collect() | ||
missionDataSource.clearMissionData().collect() | ||
} | ||
} |
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
16 changes: 16 additions & 0 deletions
16
...on/src/main/java/com/goalpanzi/mission_mate/core/navigation/AuthNavigationEventHandler.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,16 @@ | ||
package com.goalpanzi.mission_mate.core.navigation | ||
|
||
import kotlinx.coroutines.flow.MutableSharedFlow | ||
import kotlinx.coroutines.flow.SharedFlow | ||
import kotlinx.coroutines.flow.asSharedFlow | ||
import javax.inject.Inject | ||
|
||
class AuthNavigationEventHandler @Inject constructor() : NavigationEventHandler { | ||
|
||
private val _routeToNavigate = MutableSharedFlow<String>() | ||
override val routeToNavigate: SharedFlow<String> = _routeToNavigate.asSharedFlow() | ||
|
||
override suspend fun triggerRouteToNavigate(route: String) { | ||
_routeToNavigate.emit(route) | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...gation/src/main/java/com/goalpanzi/mission_mate/core/navigation/NavigationEventHandler.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,9 @@ | ||
package com.goalpanzi.mission_mate.core.navigation | ||
|
||
import kotlinx.coroutines.flow.SharedFlow | ||
|
||
interface NavigationEventHandler { | ||
val routeToNavigate : SharedFlow<String> | ||
|
||
suspend fun triggerRouteToNavigate(route : String) | ||
} |
26 changes: 26 additions & 0 deletions
26
...avigation/src/main/java/com/goalpanzi/mission_mate/core/navigation/di/NavigationModule.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,26 @@ | ||
package com.goalpanzi.mission_mate.core.navigation.di | ||
|
||
import com.goalpanzi.mission_mate.core.navigation.AuthNavigationEventHandler | ||
import com.goalpanzi.mission_mate.core.navigation.NavigationEventHandler | ||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import javax.inject.Qualifier | ||
import javax.inject.Singleton | ||
|
||
@Retention(AnnotationRetention.RUNTIME) | ||
@Qualifier | ||
annotation class AuthNavigation | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
abstract class NavigationModule { | ||
|
||
@AuthNavigation | ||
@Binds | ||
@Singleton | ||
abstract fun bindAuthNavigationEventHandler( | ||
impl : AuthNavigationEventHandler | ||
) : NavigationEventHandler | ||
} |
5 changes: 5 additions & 0 deletions
5
core/network/src/main/java/com/goalpanzi/mission_mate/core/network/TokenExpirationHandler.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,5 @@ | ||
package com.goalpanzi.mission_mate.core.network | ||
|
||
interface TokenExpirationHandler { | ||
suspend fun handleRefreshTokenExpiration() | ||
} |
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
3 changes: 2 additions & 1 deletion
3
...ion_mate/core/network/TokenInterceptor.kt → ...e/network/interceptor/TokenInterceptor.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
Oops, something went wrong.