Closes #509: guest users cannot share and unshare

This commit is contained in:
bgamard 2021-01-21 17:58:36 +01:00
parent 1e0f8e2484
commit a6cbacae72
4 changed files with 12 additions and 8 deletions

View File

@ -55,7 +55,7 @@ public class ShareResource extends BaseResource {
public Response add( public Response add(
@FormParam("id") String documentId, @FormParam("id") String documentId,
@FormParam("name") String name) { @FormParam("name") String name) {
if (!authenticate()) { if (!authenticate() || principal.isGuest()) {
throw new ForbiddenClientException(); throw new ForbiddenClientException();
} }
@ -119,7 +119,7 @@ public class ShareResource extends BaseResource {
@Path("{id: [a-z0-9\\-]+}") @Path("{id: [a-z0-9\\-]+}")
public Response delete( public Response delete(
@PathParam("id") String id) { @PathParam("id") String id) {
if (!authenticate()) { if (!authenticate() || principal.isGuest()) {
throw new ForbiddenClientException(); throw new ForbiddenClientException();
} }

View File

@ -28,9 +28,10 @@ angular.module('docs').controller('Login', function(Restangular, $scope, $rootSc
}); });
if($stateParams.redirectState !== undefined && $stateParams.redirectParams !== undefined) { if($stateParams.redirectState !== undefined && $stateParams.redirectParams !== undefined) {
$state.go($stateParams.redirectState, JSON.parse($stateParams.redirectParams)).catch(function(){ $state.go($stateParams.redirectState, JSON.parse($stateParams.redirectParams))
$state.go('document.default'); .catch(function() {
}); $state.go('document.default');
});
} else { } else {
$state.go('document.default'); $state.go('document.default');
} }

View File

@ -3,7 +3,7 @@
/** /**
* Document view controller. * Document view controller.
*/ */
angular.module('docs').controller('DocumentView', function ($scope, $state, $stateParams, $location, $dialog, $uibModal, Restangular, $translate) { angular.module('docs').controller('DocumentView', function ($scope, $rootScope, $state, $stateParams, $location, $dialog, $uibModal, Restangular, $translate) {
// Load document data from server // Load document data from server
Restangular.one('document', $stateParams.id).get().then(function (data) { Restangular.one('document', $stateParams.id).get().then(function (data) {
$scope.document = data; $scope.document = data;
@ -111,10 +111,13 @@ angular.module('docs').controller('DocumentView', function ($scope, $state, $sta
var title = $translate.instant('document.view.shared_document_title'); var title = $translate.instant('document.view.shared_document_title');
var msg = $translate.instant('document.view.shared_document_message', { link: link }); var msg = $translate.instant('document.view.shared_document_message', { link: link });
var btns = [ var btns = [
{result: 'unshare', label: $translate.instant('unshare'), cssClass: 'btn-danger'},
{result: 'close', label: $translate.instant('close')} {result: 'close', label: $translate.instant('close')}
]; ];
if ($rootScope.userInfo.username !== 'guest') {
btns.unshift({result: 'unshare', label: $translate.instant('unshare'), cssClass: 'btn-danger'});
}
$dialog.messageBox(title, msg, btns, function (result) { $dialog.messageBox(title, msg, btns, function (result) {
if (result === 'unshare') { if (result === 'unshare') {
// Unshare this document and update the local shares // Unshare this document and update the local shares

View File

@ -50,7 +50,7 @@
</h1> </h1>
<p ng-show="document.writable"> <p ng-show="document.writable">
<button class="btn btn-sm btn-info" ng-click="share()"> <button class="btn btn-sm btn-info" ng-click="share()" ng-show="userInfo.username != 'guest'">
<span class="fas fa-share"></span> {{ 'share' | translate }} <span class="fas fa-share"></span> {{ 'share' | translate }}
</button> </button>