Skip to content

Commit 1f05f39

Browse files
Merge pull request #329 from davidwatkins73/waltz-327-auth-btn
Auth Source edit btn perms
2 parents 0758690 + ea6e0d1 commit 1f05f39

3 files changed

Lines changed: 21 additions & 9 deletions

File tree

waltz-ng/client/auth-sources/edit.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,10 @@ function editController($state,
8888
};
8989
authSourceStore
9090
.insert(insertRequest)
91-
.then(refresh)
92-
.then(() => notification.success('Authoritative Sources updated'));
91+
.then(
92+
() => notification.success('Authoritative Sources updated'),
93+
(e) => notification.error('Update failed, ' + e.data.message || e.statusText))
94+
.then(refresh);
9395
}
9496
}
9597

waltz-ng/client/org-units/unit-view.html

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,14 @@
7878
<!-- AUTH-FLOWS -->
7979
<waltz-section name="Authoritative Sources"
8080
id="flows-section">
81-
<waltz-section-actions >
82-
<a waltz-has-role="AUTHORITATIVE_SOURCE_EDITOR"
83-
ng-if="ctrl.showAuthSourceEditBtn"
84-
ui-sref="main.auth-sources.edit (ctrl.entityRef)"
85-
class="btn btn-xs btn-primary">
86-
Edit
87-
</a>
81+
<waltz-section-actions>
82+
<span waltz-has-role="AUTHORITATIVE_SOURCE_EDITOR">
83+
<a ng-if="ctrl.showAuthSourceEditBtn"
84+
ui-sref="main.auth-sources.edit (ctrl.entityRef)"
85+
class="btn btn-xs btn-primary">
86+
Edit
87+
</a>
88+
</span>
8889
<button class="btn btn-xs waltz-btn-transparent"
8990
ng-click="ctrl.visibility.authOverlay = ! ctrl.visibility.authOverlay">
9091
<waltz-icon name="map-signs"></waltz-icon>

waltz-web/src/main/java/com/khartec/waltz/web/endpoints/api/AuthoritativeSourceEndpoint.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@
2424
import com.khartec.waltz.model.authoritativesource.Rating;
2525
import com.khartec.waltz.model.changelog.ChangeLog;
2626
import com.khartec.waltz.model.changelog.ImmutableChangeLog;
27+
import com.khartec.waltz.model.user.Role;
2728
import com.khartec.waltz.service.authoritative_source.AuthoritativeSourceService;
2829
import com.khartec.waltz.service.changelog.ChangeLogService;
30+
import com.khartec.waltz.service.user.UserRoleService;
2931
import com.khartec.waltz.web.endpoints.Endpoint;
3032
import org.springframework.beans.factory.annotation.Autowired;
3133
import org.springframework.stereotype.Service;
@@ -44,16 +46,20 @@ public class AuthoritativeSourceEndpoint implements Endpoint {
4446

4547
private final AuthoritativeSourceService authoritativeSourceService;
4648
private final ChangeLogService changeLogService;
49+
private final UserRoleService userRoleService;
4750

4851

4952
@Autowired
5053
public AuthoritativeSourceEndpoint(
5154
AuthoritativeSourceService authoritativeSourceService,
55+
UserRoleService userRoleService,
5256
ChangeLogService changeLogService) {
5357
checkNotNull(authoritativeSourceService, "authoritativeSourceService must not be null");
58+
checkNotNull(userRoleService, "userRoleService cannot be null");
5459
checkNotNull(changeLogService, "changeLogService must not be null");
5560

5661
this.authoritativeSourceService = authoritativeSourceService;
62+
this.userRoleService = userRoleService;
5763
this.changeLogService = changeLogService;
5864
}
5965

@@ -70,13 +76,15 @@ public void register() {
7076
-> authoritativeSourceService.findByApplicationId(getId(request)));
7177

7278
post(mkPath(BASE_URL, "id", ":id"), (request, response) -> {
79+
requireRole(userRoleService, request, Role.AUTHORITATIVE_SOURCE_EDITOR);
7380
String ratingStr = request.body();
7481
Rating rating = Rating.valueOf(ratingStr);
7582
authoritativeSourceService.update(getId(request), rating);
7683
return "done";
7784
});
7885

7986
delete(mkPath(BASE_URL, "id", ":id"), (request, response) -> {
87+
requireRole(userRoleService, request, Role.AUTHORITATIVE_SOURCE_EDITOR);
8088
long id = getId(request);
8189
AuthoritativeSource authSource = authoritativeSourceService.getById(id);
8290
if (authSource == null) {
@@ -103,6 +111,7 @@ public void register() {
103111
});
104112

105113
post(mkPath(BASE_URL, "kind", ":kind", ":id", ":dataType", ":appId"), (request, response) -> {
114+
requireRole(userRoleService, request, Role.AUTHORITATIVE_SOURCE_EDITOR);
106115
EntityReference parentRef = getEntityReference(request);
107116
String dataType = request.params("dataType");
108117
Long appId = getLong(request, "appId");

0 commit comments

Comments
 (0)