fix notification, inapp notification permissions

This commit is contained in:
amentis 2024-01-12 15:57:38 +02:00
parent 141ef488e5
commit 951f34e0cc
10 changed files with 58 additions and 11 deletions

View File

@ -44,7 +44,6 @@ public class InAppNotificationController {
private final BuilderFactory builderFactory;
private final AuditService auditService;
private final NotificationService notificationService;
private final CensorFactory censorFactory;
private final QueryFactory queryFactory;
private final MessageSource messageSource;
@ -61,7 +60,6 @@ public class InAppNotificationController {
InAppNotificationService inAppNotificationService, UserScope userScope, ErrorThesaurusProperties errors) {
this.builderFactory = builderFactory;
this.auditService = auditService;
this.notificationService = notificationService;
this.censorFactory = censorFactory;
this.queryFactory = queryFactory;
this.messageSource = messageSource;
@ -159,7 +157,7 @@ public class InAppNotificationController {
public void Delete(@PathVariable("id") UUID id) throws MyForbiddenException, InvalidApplicationException {
logger.debug(new MapLogEntry("deleting" + Notification.class.getSimpleName()).And("id", id));
this.notificationService.deleteAndSave(id);
this.inAppNotificationService.deleteAndSave(id);
this.auditService.track(AuditableAction.InApp_Notification_Delete, "id", id);

View File

@ -85,6 +85,12 @@ permissions:
clients: [ ]
allowAnonymous: true
allowAuthenticated: false
DeleteNotification:
roles:
- Admin
clients: [ ]
allowAnonymous: false
allowAuthenticated: false
#Tenant Configuration
BrowseTenantConfiguration:
roles:
@ -159,3 +165,17 @@ permissions:
clients: [ ]
allowAnonymous: false
allowAuthenticated: false
# In App Notification Permissions
BrowseInAppNotification:
roles:
- Admin
clients: [ ]
allowAnonymous: false
allowAuthenticated: false
DeleteInAppNotification:
roles:
- Admin
clients: [ ]
allowAnonymous: false
allowAuthenticated: false

View File

@ -85,6 +85,12 @@ permissions:
clients: [ ]
allowAnonymous: true
allowAuthenticated: false
DeleteNotification:
roles:
- Admin
clients: [ ]
allowAnonymous: false
allowAuthenticated: false
#Tenant Configuration
BrowseTenantConfiguration:
roles:
@ -159,3 +165,17 @@ permissions:
clients: [ ]
allowAnonymous: false
allowAuthenticated: false
# In App Notification Permissions
BrowseInAppNotification:
roles:
- Admin
clients: [ ]
allowAnonymous: false
allowAuthenticated: false
DeleteInAppNotification:
roles:
- Admin
clients: [ ]
allowAnonymous: false
allowAuthenticated: false

View File

@ -34,6 +34,10 @@ public final class Permission {
public static String EditNotificationTemplate = "EditNotificationTemplate";
public static String DeleteNotificationTemplate = "DeleteNotificationTemplate";
//InApp Notification
public static final String BrowseInAppNotification = "BrowseInAppNotification";
public static String DeleteInAppNotification = "DeleteInAppNotification";
// UI Pages
public static String ViewTenantConfigurationPage = "ViewTenantConfigurationPage";
public static String ViewNotificationPage = "ViewNotificationPage";

View File

@ -27,6 +27,6 @@ public class InAppNotificationCensor extends BaseCensor {
public void censor(FieldSet fields) {
logger.debug(new DataLogEntry("censoring fields", fields));
if (this.isEmpty(fields)) return;
this.authService.authorizeForce(Permission.BrowseNotification);
this.authService.authorizeForce(Permission.BrowseInAppNotification);
}
}

View File

@ -86,8 +86,8 @@ public class InAppNotificationServiceImpl implements InAppNotificationService{
public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException {
logger.debug("deleting tenant: {}", id);
this.authService.authorizeForce(Permission.DeleteNotification);
logger.debug("deleting inapp notification: {}", id);
this.authService.authorizeForce(Permission.DeleteInAppNotification);
this.deleterFactory.deleter(InAppNotificationDeleter.class).deleteAndSaveByIds(List.of(id));
}
}

View File

@ -181,7 +181,7 @@ public class NotificationServiceImpl implements NotificationService {
@Override
public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException {
logger.debug("deleting tenant: {}", id);
logger.debug("deleting notification: {}", id);
this.authService.authorizeForce(Permission.DeleteNotification);
this.deleterFactory.deleter(NotificationDeleter.class).deleteAndSaveByIds(List.of(id));
}

View File

@ -7,8 +7,7 @@
</div>
<div [ngClass]="{'contact-container': !isDialog}" class="row">
<div class="col-md-12">
<mat-form-field class="full-width mb-2">
<!-- <input matInput placeholder="{{'CONTACT.SUPPORT.SUBJECT' | translate}}" [(ngModel)]="formGroup.subject" name="contactSupportSubject" required> -->
<mat-form-field class="mat-form-field">
<input matInput placeholder="{{'CONTACT.SUPPORT.SUBJECT' | translate}}" type="text" name="subject" formControlName="subject" required>
<mat-error *ngIf="formGroup.get('subject').hasError('backendError')">
{{formGroup.get('subject').getError('backendError').message}}</mat-error>
@ -17,7 +16,7 @@
</mat-form-field>
</div>
<div class="col-md-12">
<mat-form-field class="full-width">
<mat-form-field class="mat-form-field">
<textarea matInput placeholder="{{'CONTACT.SUPPORT.DESCRIPTION' | translate}}" type="text" name="description" formControlName="description" required></textarea>
<mat-error *ngIf="formGroup.get('description').hasError('backendError')">
{{formGroup.get('description').getError('backendError').message}}</mat-error>

View File

@ -23,6 +23,10 @@ img {
padding-right: 1em;
}
.mat-form-field {
width: 100%;
}
.send-btn {
background: #ffffff 0% 0% no-repeat padding-box;
border: 1px solid var(--primary-color);

View File

@ -12,6 +12,7 @@ import { InAppNotificationLookup } from '@app/core/query/inapp-notification.look
import { InAppNotificationService } from '@app/core/services/inapp-notification/inapp-notification.service';
import { takeUntil } from 'rxjs/operators';
import { nameof } from 'ts-simple-nameof';
import { IsActive } from '@app/core/common/enum/is-active.enum';
@Component({
selector: 'app-mine-inapp-notification-listing-dialog',
@ -46,6 +47,7 @@ export class MineInAppNotificationListingDialogComponent extends BaseComponent i
};
lookup.page = { offset: 0, size: 10 };
lookup.order = { items: ['-' + nameof<InAppNotification>(x => x.createdAt)] };
lookup.isActive = [IsActive.Active];
this.inappNotificationService.query(lookup)
.pipe(takeUntil(this._destroyed))
.subscribe(