Skip to content

Commit

Permalink
SAK-33403 Can only post via XHR if post.create is set. (sakaiproject#…
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianfish authored Sep 26, 2017
1 parent 9357b4c commit e8e8ee7
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.sakaiproject.commons.impl;

import org.apache.commons.lang.StringUtils;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
Expand Down Expand Up @@ -95,8 +97,12 @@ public boolean canCurrentUserEditPost(Post post) {
String currentUser = sakaiProxy.getCurrentUserId();

// If the current user is authenticated and the post author, yes.
if (currentUser != null && currentUser.equals(post.getCreatorId()) && sakaiProxy.isAllowedFunction(CommonsFunctions.POST_UPDATE_OWN, post.getSiteId())) {
return true;
if (currentUser != null && currentUser.equals(post.getCreatorId())) {
if (StringUtils.isEmpty(post.getId())) {
return sakaiProxy.isAllowedFunction(CommonsFunctions.POST_CREATE, post.getSiteId());
} else {
return sakaiProxy.isAllowedFunction(CommonsFunctions.POST_UPDATE_OWN, post.getSiteId());
}
}

return false;
Expand Down

0 comments on commit e8e8ee7

Please sign in to comment.