1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-19 13:19:43 +02:00

Fix space permissions group vs. user role overriding

This commit is contained in:
sauls8t 2018-03-27 11:33:43 +01:00
parent e1d2d4c037
commit ad4030bc17
11 changed files with 691 additions and 680 deletions

View file

@ -73,7 +73,7 @@ func (s Scope) GetUserSpacePermissions(ctx domain.RequestContext, spaceID string
WHERE p.orgid=? AND p.location='space' AND refid=? AND p.who='role' AND (r.userid=? OR r.userid='0')`,
ctx.OrgID, spaceID, ctx.UserID, ctx.OrgID, spaceID, ctx.UserID)
if err == sql.ErrNoRows {
if err == sql.ErrNoRows || len(r) == 0 {
err = nil
r = []permission.Permission{}
}

View file

@ -42,7 +42,7 @@ func main() {
rt.Product = env.ProdInfo{}
rt.Product.Major = "1"
rt.Product.Minor = "59"
rt.Product.Patch = "0"
rt.Product.Patch = "1"
rt.Product.Version = fmt.Sprintf("%s.%s.%s", rt.Product.Major, rt.Product.Minor, rt.Product.Patch)
rt.Product.Edition = "Community"
rt.Product.Title = fmt.Sprintf("%s Edition", rt.Product.Edition)

File diff suppressed because one or more lines are too long

View file

@ -19,6 +19,7 @@ export default Component.extend(ModalMixin, {
groupSvc: service('group'),
spaceSvc: service('folder'),
userSvc: service('user'),
router: service(),
appMeta: service(),
store: service(),
spacePermissions: null,
@ -26,6 +27,8 @@ export default Component.extend(ModalMixin, {
searchText: '',
didReceiveAttrs() {
this._super(...arguments);
let spacePermissions = A([]);
let constants = this.get('constants');
@ -77,7 +80,6 @@ export default Component.extend(ModalMixin, {
permissionRecord(who, whoId, name) {
let raw = {
id: whoId,
orgId: this.get('folder.orgId'),
folderId: this.get('folder.id'),
whoId: whoId,
@ -161,6 +163,7 @@ export default Component.extend(ModalMixin, {
this.get('spaceSvc').savePermissions(folder.get('id'), payload).then(() => {
this.modalClose('#space-permission-modal');
this.get('onRefresh')();
});
},

View file

@ -2,9 +2,13 @@ import ApplicationSerializer from './application';
export default ApplicationSerializer.extend({
normalize(modelClass, resourceHash) {
let id = '0';
if (resourceHash.whoId) id = resourceHash.whoId;
if (resourceHash.id) id = resourceHash.id;
return {
data: {
id: resourceHash.whoId ? resourceHash.whoId : 0,
id: id,
type: modelClass.modelName,
attributes: resourceHash
}

View file

@ -122,6 +122,7 @@ export default BaseService.extend({
if (is.not.array(response)) response = [];
data = response.map((obj) => {
obj.id = 'sp-' + obj.id;
let data = this.get('store').normalize('space-permission', obj);
return this.get('store').push(data);
});
@ -165,6 +166,7 @@ export default BaseService.extend({
let url = `space/${folderId}/permissions/user`;
return this.get('ajax').request(url).then((response) => {
response.id = 'u-' + response.id;
let data = this.get('store').normalize('space-permission', response);
let data2 = this.get('store').push(data);
this.set('permissions', data2);

View file

@ -15,20 +15,20 @@
@top-right {
font-size: 12px;
content: string(doctitle);
color: $color-off-black;
// content: string(doctitle);
}
@bottom-left {
font-size: 12px;
content: 'Exported from Documize';
color: $color-off-black;
// content: 'Exported from Documize';
}
@bottom-right {
content: counter(page);
font-size: 12px;
color: $color-off-black;
// content: counter(page);
}
}

View file

@ -212,4 +212,4 @@
{{/toolbar/t-toolbar}}
{{folder/permission-admin folders=spaces folder=space}}
{{folder/permission-admin folders=spaces folder=space onRefresh=onRefresh}}

View file

@ -15,6 +15,7 @@ package permission
// This data structure is made from database permission records for the space,
// and it is designed to be sent to HTTP clients (web, mobile).
type Record struct {
ID uint64 `json:"id"`
OrgID string `json:"orgId"`
SpaceID string `json:"folderId"`
WhoID string `json:"whoId"`
@ -40,6 +41,7 @@ func DecodeUserPermissions(perm []Permission) (r Record) {
r = Record{}
if len(perm) > 0 {
r.ID = perm[0].ID
r.OrgID = perm[0].OrgID
r.WhoID = perm[0].WhoID
r.Who = perm[0].Who