Check for permission changes
This commit is contained in:
parent
404436e54a
commit
0b7425d3b0
|
|
@ -231,13 +231,32 @@ Middleware<AppState> _createRefreshRequest(AuthRepository repository) {
|
||||||
includeStatic: action.includeStatic || state.staticState.isStale,
|
includeStatic: action.includeStatic || state.staticState.isStale,
|
||||||
)
|
)
|
||||||
.then((data) {
|
.then((data) {
|
||||||
if (action.clearData && !company.isLarge) {
|
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(ClearData());
|
||||||
|
store.dispatch(RefreshData(completer: action.completer));
|
||||||
|
} else {
|
||||||
|
if (action.clearData && !company.isLarge) {
|
||||||
|
store.dispatch(ClearData());
|
||||||
|
}
|
||||||
|
store.dispatch(LoadAccountSuccess(
|
||||||
|
completer: action.completer,
|
||||||
|
loginResponse: data,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
store.dispatch(LoadAccountSuccess(
|
|
||||||
completer: action.completer,
|
|
||||||
loginResponse: data,
|
|
||||||
));
|
|
||||||
}).catchError((Object error) {
|
}).catchError((Object error) {
|
||||||
final message = _parseError('$error');
|
final message = _parseError('$error');
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue