Check for permission changes
This commit is contained in:
parent
404436e54a
commit
0b7425d3b0
|
|
@ -231,6 +231,24 @@ Middleware<AppState> _createRefreshRequest(AuthRepository repository) {
|
|||
includeStatic: action.includeStatic || state.staticState.isStale,
|
||||
)
|
||||
.then((data) {
|
||||
bool permissionsWereChanged = false;
|
||||
data.userCompanies.forEach((userCompany) {
|
||||
state.userCompanyStates.forEach((userCompanyState) {
|
||||
if (userCompany.company.id == userCompanyState.company.id) {
|
||||
if (userCompanyState.userCompany.permissionsUpdatedAt > 0 &&
|
||||
userCompany.permissionsUpdatedAt !=
|
||||
userCompanyState.userCompany.permissionsUpdatedAt) {
|
||||
permissionsWereChanged = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
if (permissionsWereChanged) {
|
||||
print('## Permissions were changed');
|
||||
store.dispatch(ClearData());
|
||||
store.dispatch(RefreshData(completer: action.completer));
|
||||
} else {
|
||||
if (action.clearData && !company.isLarge) {
|
||||
store.dispatch(ClearData());
|
||||
}
|
||||
|
|
@ -238,6 +256,7 @@ Middleware<AppState> _createRefreshRequest(AuthRepository repository) {
|
|||
completer: action.completer,
|
||||
loginResponse: data,
|
||||
));
|
||||
}
|
||||
}).catchError((Object error) {
|
||||
final message = _parseError('$error');
|
||||
if (action.completer != null) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue