Skip to content
Snippets Groups Projects
Commit 818f225a authored by Taras's avatar Taras
Browse files

Add switchToSessionWithId logic

parent 4eead726
No related branches found
No related tags found
No related merge requests found
...@@ -152,6 +152,11 @@ interface AuthenticationService { ...@@ -152,6 +152,11 @@ interface AuthenticationService {
deviceId: String? = null deviceId: String? = null
): Session ): Session
/**
* Added for switch user
*/
suspend fun switchToSessionWithId(id: String)
/** /**
* Added for switch user * Added for switch user
*/ */
......
...@@ -74,10 +74,15 @@ internal class SessionManager @Inject constructor( ...@@ -74,10 +74,15 @@ internal class SessionManager @Inject constructor(
} }
//Added for switch user //Added for switch user
fun getAllSessionParams(): List<SessionParams> { suspend fun setActiveSessionAsLast(sessionId: String) {
return sessionParamsStore.getAll() val sessionParams = sessionParamsStore.get(sessionId) ?: return
sessionParamsStore.delete(sessionId)
sessionParamsStore.save(sessionParams)
} }
//Added for switch user
fun getAllSessionParams(): List<SessionParams> = sessionParamsStore.getAll()
//Added for switch user //Added for switch user
suspend fun removeSession(sessionId: String) { suspend fun removeSession(sessionId: String) {
sessionComponents.remove(sessionId) sessionComponents.remove(sessionId)
......
...@@ -487,6 +487,11 @@ internal class DefaultAuthenticationService @Inject constructor( ...@@ -487,6 +487,11 @@ internal class DefaultAuthenticationService @Inject constructor(
} }
} }
//Added for switch user
override suspend fun switchToSessionWithId(id: String) {
sessionManager.setActiveSessionAsLast(id)
}
//Added for switch user //Added for switch user
override fun getAllAuthSessionsParams(): List<SessionParams> = sessionManager.getAllSessionParams() override fun getAllAuthSessionsParams(): List<SessionParams> = sessionManager.getAllSessionParams()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment