You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I am using your architecture
I got some error when user success login, I save the token from response and use it as header
I've already save it to preference but the apiHeaders.token not updated it and still null
Here my login presenter
`override fun doLogin(nrp: String, password: String) {
interactor?.let {
compositeDisposable.add(
it.doLogin(LoginRequest.ServerLoginRequest(username = nrp, password = password))
.compose(schedulerProvider.ioToMainObservableScheduler())
.subscribe({res ->
getView()?.let {v ->
v.loginSuccess()
}
interactor?.setToken("${res.tokenType} ${res.accessToken}").let {
loadUserInfo()
}
}, {err ->
val anError = err as ANError
if (anError.errorCode == 401) {
getView()?.loginFailure("NRP atau password tidak sesuai")
}
})
)
}
}
override fun loadUserInfo() {
interactor?.let {
compositeDisposable.add(
it.loadUser()
.compose(schedulerProvider.ioToMainObservableScheduler())
.subscribe ({d ->
interactor?.setUserInfo(d.data)
getView()?.userInfoSuccess()
}, {err ->
})
)
}
}`
LoginInteractor
`override fun doLogin(request: LoginRequest.ServerLoginRequest): Observable = apiHelper.performServerLogin(request)
override fun loadUser(): Observable<DataUserResponse> = apiHelper.performInfoUser()
override fun sendToken(request: LoginRequest.UpdateFcmRequest): Observable<DefaultResponse> = apiHelper.performUpdateFcm(request)
override fun setToken(token: String) {
preferenceHelper.setToken(token)
}`
Hi, I am using your architecture
I got some error when user success login, I save the token from response and use it as header
I've already save it to preference but the apiHeaders.token not updated it and still null
Here my login presenter
`override fun doLogin(nrp: String, password: String) {
interactor?.let {
compositeDisposable.add(
it.doLogin(LoginRequest.ServerLoginRequest(username = nrp, password = password))
.compose(schedulerProvider.ioToMainObservableScheduler())
.subscribe({res ->
getView()?.let {v ->
v.loginSuccess()
}
LoginInteractor
`override fun doLogin(request: LoginRequest.ServerLoginRequest): Observable = apiHelper.performServerLogin(request)
AppModule.kt
@Provides @Singleton internal fun provideProtectedApiHeader(@AcceptHeader accept: String, preferenceHelper: PreferenceHelper) : ApiHeader.ProtectedApiHeader = ApiHeader.ProtectedApiHeader(accept = accept, token = preferenceHelper.getToken())
thanks
The text was updated successfully, but these errors were encountered: