Commit 95fa0705 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

added auth validate method

parent 323bf812
package com.biganto.visual.roompark.di.dagger package com.biganto.visual.roompark.di.dagger
import com.biganto.visual.androidplayer.data.repository.local.ILocalStore import com.biganto.visual.androidplayer.data.repository.local.ILocalStore
import com.biganto.visual.roompark.data.local.UserState
import com.biganto.visual.roompark.data.repository.api.IRoomParkApi import com.biganto.visual.roompark.data.repository.api.IRoomParkApi
import com.biganto.visual.roompark.data.repository.db.IDb import com.biganto.visual.roompark.data.repository.db.IDb
import com.biganto.visual.roompark.data.repository.mapper.fromRaw import com.biganto.visual.roompark.data.repository.mapper.fromRaw
...@@ -56,6 +57,13 @@ class AppModule() { ...@@ -56,6 +57,13 @@ class AppModule() {
.flatMap{ db.upsertUser(it) } .flatMap{ db.upsertUser(it) }
.doOnNext { local.setRecentUser(it.uuid.toString()) } .doOnNext { local.setRecentUser(it.uuid.toString()) }
.map(::fromEntity) .map(::fromEntity)
override fun validateAuthState(): Observable<Boolean> = local.recentUser()
.map { when(it){
is UserState.NotAuthenticated -> false
is UserState.Authenticated -> true
else ->false
} }
} }
@Module() @Module()
......
...@@ -11,4 +11,5 @@ import io.reactivex.Observable ...@@ -11,4 +11,5 @@ import io.reactivex.Observable
interface AuthContract { interface AuthContract {
fun signIn(email:String,password:String) : Observable<AuthInfoModel> fun signIn(email:String,password:String) : Observable<AuthInfoModel>
fun signOut() : Completable fun signOut() : Completable
fun validateAuthState(): Observable<Boolean>
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment