mirror of
https://github.com/documize/community.git
synced 2025-07-19 21:29:42 +02:00
Fix space permissions group vs. user role overriding
This commit is contained in:
parent
e1d2d4c037
commit
ad4030bc17
11 changed files with 691 additions and 680 deletions
|
@ -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')`,
|
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)
|
ctx.OrgID, spaceID, ctx.UserID, ctx.OrgID, spaceID, ctx.UserID)
|
||||||
|
|
||||||
if err == sql.ErrNoRows {
|
if err == sql.ErrNoRows || len(r) == 0 {
|
||||||
err = nil
|
err = nil
|
||||||
r = []permission.Permission{}
|
r = []permission.Permission{}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ func main() {
|
||||||
rt.Product = env.ProdInfo{}
|
rt.Product = env.ProdInfo{}
|
||||||
rt.Product.Major = "1"
|
rt.Product.Major = "1"
|
||||||
rt.Product.Minor = "59"
|
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.Version = fmt.Sprintf("%s.%s.%s", rt.Product.Major, rt.Product.Minor, rt.Product.Patch)
|
||||||
rt.Product.Edition = "Community"
|
rt.Product.Edition = "Community"
|
||||||
rt.Product.Title = fmt.Sprintf("%s Edition", rt.Product.Edition)
|
rt.Product.Title = fmt.Sprintf("%s Edition", rt.Product.Edition)
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -19,6 +19,7 @@ export default Component.extend(ModalMixin, {
|
||||||
groupSvc: service('group'),
|
groupSvc: service('group'),
|
||||||
spaceSvc: service('folder'),
|
spaceSvc: service('folder'),
|
||||||
userSvc: service('user'),
|
userSvc: service('user'),
|
||||||
|
router: service(),
|
||||||
appMeta: service(),
|
appMeta: service(),
|
||||||
store: service(),
|
store: service(),
|
||||||
spacePermissions: null,
|
spacePermissions: null,
|
||||||
|
@ -26,6 +27,8 @@ export default Component.extend(ModalMixin, {
|
||||||
searchText: '',
|
searchText: '',
|
||||||
|
|
||||||
didReceiveAttrs() {
|
didReceiveAttrs() {
|
||||||
|
this._super(...arguments);
|
||||||
|
|
||||||
let spacePermissions = A([]);
|
let spacePermissions = A([]);
|
||||||
let constants = this.get('constants');
|
let constants = this.get('constants');
|
||||||
|
|
||||||
|
@ -77,7 +80,6 @@ export default Component.extend(ModalMixin, {
|
||||||
|
|
||||||
permissionRecord(who, whoId, name) {
|
permissionRecord(who, whoId, name) {
|
||||||
let raw = {
|
let raw = {
|
||||||
id: whoId,
|
|
||||||
orgId: this.get('folder.orgId'),
|
orgId: this.get('folder.orgId'),
|
||||||
folderId: this.get('folder.id'),
|
folderId: this.get('folder.id'),
|
||||||
whoId: whoId,
|
whoId: whoId,
|
||||||
|
@ -161,6 +163,7 @@ export default Component.extend(ModalMixin, {
|
||||||
|
|
||||||
this.get('spaceSvc').savePermissions(folder.get('id'), payload).then(() => {
|
this.get('spaceSvc').savePermissions(folder.get('id'), payload).then(() => {
|
||||||
this.modalClose('#space-permission-modal');
|
this.modalClose('#space-permission-modal');
|
||||||
|
this.get('onRefresh')();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,13 @@ import ApplicationSerializer from './application';
|
||||||
|
|
||||||
export default ApplicationSerializer.extend({
|
export default ApplicationSerializer.extend({
|
||||||
normalize(modelClass, resourceHash) {
|
normalize(modelClass, resourceHash) {
|
||||||
|
let id = '0';
|
||||||
|
if (resourceHash.whoId) id = resourceHash.whoId;
|
||||||
|
if (resourceHash.id) id = resourceHash.id;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
data: {
|
data: {
|
||||||
id: resourceHash.whoId ? resourceHash.whoId : 0,
|
id: id,
|
||||||
type: modelClass.modelName,
|
type: modelClass.modelName,
|
||||||
attributes: resourceHash
|
attributes: resourceHash
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,6 +122,7 @@ export default BaseService.extend({
|
||||||
if (is.not.array(response)) response = [];
|
if (is.not.array(response)) response = [];
|
||||||
|
|
||||||
data = response.map((obj) => {
|
data = response.map((obj) => {
|
||||||
|
obj.id = 'sp-' + obj.id;
|
||||||
let data = this.get('store').normalize('space-permission', obj);
|
let data = this.get('store').normalize('space-permission', obj);
|
||||||
return this.get('store').push(data);
|
return this.get('store').push(data);
|
||||||
});
|
});
|
||||||
|
@ -165,6 +166,7 @@ export default BaseService.extend({
|
||||||
let url = `space/${folderId}/permissions/user`;
|
let url = `space/${folderId}/permissions/user`;
|
||||||
|
|
||||||
return this.get('ajax').request(url).then((response) => {
|
return this.get('ajax').request(url).then((response) => {
|
||||||
|
response.id = 'u-' + response.id;
|
||||||
let data = this.get('store').normalize('space-permission', response);
|
let data = this.get('store').normalize('space-permission', response);
|
||||||
let data2 = this.get('store').push(data);
|
let data2 = this.get('store').push(data);
|
||||||
this.set('permissions', data2);
|
this.set('permissions', data2);
|
||||||
|
|
|
@ -15,20 +15,20 @@
|
||||||
|
|
||||||
@top-right {
|
@top-right {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
content: string(doctitle);
|
|
||||||
color: $color-off-black;
|
color: $color-off-black;
|
||||||
|
// content: string(doctitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@bottom-left {
|
@bottom-left {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
content: 'Exported from Documize';
|
|
||||||
color: $color-off-black;
|
color: $color-off-black;
|
||||||
|
// content: 'Exported from Documize';
|
||||||
}
|
}
|
||||||
|
|
||||||
@bottom-right {
|
@bottom-right {
|
||||||
content: counter(page);
|
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
color: $color-off-black;
|
color: $color-off-black;
|
||||||
|
// content: counter(page);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -212,4 +212,4 @@
|
||||||
|
|
||||||
{{/toolbar/t-toolbar}}
|
{{/toolbar/t-toolbar}}
|
||||||
|
|
||||||
{{folder/permission-admin folders=spaces folder=space}}
|
{{folder/permission-admin folders=spaces folder=space onRefresh=onRefresh}}
|
||||||
|
|
|
@ -15,6 +15,7 @@ package permission
|
||||||
// This data structure is made from database permission records for the space,
|
// This data structure is made from database permission records for the space,
|
||||||
// and it is designed to be sent to HTTP clients (web, mobile).
|
// and it is designed to be sent to HTTP clients (web, mobile).
|
||||||
type Record struct {
|
type Record struct {
|
||||||
|
ID uint64 `json:"id"`
|
||||||
OrgID string `json:"orgId"`
|
OrgID string `json:"orgId"`
|
||||||
SpaceID string `json:"folderId"`
|
SpaceID string `json:"folderId"`
|
||||||
WhoID string `json:"whoId"`
|
WhoID string `json:"whoId"`
|
||||||
|
@ -40,6 +41,7 @@ func DecodeUserPermissions(perm []Permission) (r Record) {
|
||||||
r = Record{}
|
r = Record{}
|
||||||
|
|
||||||
if len(perm) > 0 {
|
if len(perm) > 0 {
|
||||||
|
r.ID = perm[0].ID
|
||||||
r.OrgID = perm[0].OrgID
|
r.OrgID = perm[0].OrgID
|
||||||
r.WhoID = perm[0].WhoID
|
r.WhoID = perm[0].WhoID
|
||||||
r.Who = perm[0].Who
|
r.Who = perm[0].Who
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue