public override async Task <int> SaveChangesAsync(bool acceptAllChangesOnSuccess, CancellationToken cancellationToken = new CancellationToken()) { if (_authChange == null) { //_authChange is null if not using UpdateCookieOnChange, so bypass permission change code return(await base.SaveChangesAsync(acceptAllChangesOnSuccess, cancellationToken)); } if (this.UserPermissionsMayHaveChanged()) { _authChange?.AddOrUpdate(this); } return(await base.SaveChangesAsync(acceptAllChangesOnSuccess, cancellationToken)); }
//YOU ONLY NEED TO OVERRIDE SAVECHANGES IF YOU WANT THE "REFRESH USER CLAIMS" FEATURE //I only have to override these two versions of SaveChanges, as the other two SaveChanges versions call these public override int SaveChanges(bool acceptAllChangesOnSuccess) { if (_authChange == null) { //_authChange is null if not using UpdateCookieOnChange, so bypass permission change code return(base.SaveChanges(acceptAllChangesOnSuccess)); } if (this.UserPermissionsMayHaveChanged()) { _authChange.AddOrUpdate(this); } return(base.SaveChanges(acceptAllChangesOnSuccess)); }