Migliorata gestione di token scaduto in AuthInterceptor
This commit is contained in:
parent
26c09c02ab
commit
c6a30588e6
@ -189,6 +189,8 @@ dependencies {
|
|||||||
implementation 'io.reactivex.rxjava2:rxjava:2.1.12'
|
implementation 'io.reactivex.rxjava2:rxjava:2.1.12'
|
||||||
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
|
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
|
||||||
|
|
||||||
|
implementation 'org.greenrobot:eventbus:3.3.1'
|
||||||
|
|
||||||
//Barcode generator
|
//Barcode generator
|
||||||
implementation group: 'com.google.zxing', name: 'core', version: '3.5.3'
|
implementation group: 'com.google.zxing', name: 'core', version: '3.5.3'
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,7 +41,6 @@ public class MainContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
BarcodeManager.init(applicationContext);
|
BarcodeManager.init(applicationContext);
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
@ -63,8 +62,20 @@ public class MainContext {
|
|||||||
|
|
||||||
this.initServerStatusChecker();
|
this.initServerStatusChecker();
|
||||||
|
|
||||||
|
// EventBus.getDefault().register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
|
// public void onSessionExpired(SessionExpiredEvent event) {
|
||||||
|
// DialogSimpleMessageView.makeErrorDialog(
|
||||||
|
// new SpannedString("La sessione è scaduta. Effettua nuovamente la login"),
|
||||||
|
// null,
|
||||||
|
// () -> {
|
||||||
|
// logout(MainApplication::exit);
|
||||||
|
// })
|
||||||
|
// .show(activity.getSupportFragmentManager(), "expired-session-error");
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
private void initAuthSession(Runnable onComplete) {
|
private void initAuthSession(Runnable onComplete) {
|
||||||
this.authenticationRESTConsumer.me(obj -> {
|
this.authenticationRESTConsumer.me(obj -> {
|
||||||
|
|||||||
@ -0,0 +1,4 @@
|
|||||||
|
package it.integry.integrywmsnative.core.event;
|
||||||
|
|
||||||
|
public class SessionExpiredEvent {
|
||||||
|
}
|
||||||
@ -2,10 +2,14 @@ package it.integry.integrywmsnative.core.rest;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import io.jsonwebtoken.Claims;
|
import io.jsonwebtoken.Claims;
|
||||||
import it.integry.integrywmsnative.core.authentication.JwtUtils;
|
import it.integry.integrywmsnative.core.authentication.JwtUtils;
|
||||||
|
import it.integry.integrywmsnative.core.event.SessionExpiredEvent;
|
||||||
|
import it.integry.integrywmsnative.core.exception.UnauthorizedAccessException;
|
||||||
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
||||||
import it.integry.integrywmsnative.core.utility.UtilityDate;
|
import it.integry.integrywmsnative.core.utility.UtilityDate;
|
||||||
import it.integry.integrywmsnative.gest.login.rest.RefreshRESTConsumer;
|
import it.integry.integrywmsnative.gest.login.rest.RefreshRESTConsumer;
|
||||||
@ -45,6 +49,8 @@ public class AuthInterceptor implements Interceptor {
|
|||||||
.setRefreshTokenExpiryDate(response.getExpiryDate());
|
.setRefreshTokenExpiryDate(response.getExpiryDate());
|
||||||
|
|
||||||
SettingsManager.update();
|
SettingsManager.update();
|
||||||
|
} catch (UnauthorizedAccessException uae) {
|
||||||
|
//Globally managed
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
@ -61,4 +67,11 @@ public class AuthInterceptor implements Interceptor {
|
|||||||
} else
|
} else
|
||||||
return chain.proceed(originalRequest);
|
return chain.proceed(originalRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void notifySessionExpired() {
|
||||||
|
EventBus.getDefault().post(new SessionExpiredEvent());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -106,10 +106,9 @@ public class AccettazioneBollaPickingViewModel {
|
|||||||
this.mBolle = bolle;
|
this.mBolle = bolle;
|
||||||
this.mUseQtaBolla = useQtaOrd;
|
this.mUseQtaBolla = useQtaOrd;
|
||||||
|
|
||||||
List<SitBollaAccettazioneDTO> mSitArts = Stream.of(sitArts)
|
List<SitBollaAccettazioneDTO> mSitArts = sitArts.stream()
|
||||||
.filter(x ->
|
.filter(x -> UtilityBigDecimal.greaterThan(x.getQtaDaAccettare(), BigDecimal.ZERO))
|
||||||
UtilityBigDecimal.greaterThan(x.getQtaDaAccettare(), BigDecimal.ZERO))
|
.collect(Collectors.toList());
|
||||||
.toList();
|
|
||||||
|
|
||||||
getEmptyPickingList(mSitArts, this.mPickingList::postValue);
|
getEmptyPickingList(mSitArts, this.mPickingList::postValue);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user