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{}
|
||||||
}
|
}
|
||||||
|
@ -136,9 +136,9 @@ func (s Scope) GetCategoryPermissions(ctx domain.RequestContext, catID string) (
|
||||||
func (s Scope) GetCategoryUsers(ctx domain.RequestContext, catID string) (u []user.User, err error) {
|
func (s Scope) GetCategoryUsers(ctx domain.RequestContext, catID string) (u []user.User, err error) {
|
||||||
err = s.Runtime.Db.Select(&u, `
|
err = s.Runtime.Db.Select(&u, `
|
||||||
SELECT u.id, IFNULL(u.refid, '') AS refid, IFNULL(u.firstname, '') AS firstname, IFNULL(u.lastname, '') as lastname, u.email, u.initials, u.password, u.salt, u.reset, u.created, u.revised
|
SELECT u.id, IFNULL(u.refid, '') AS refid, IFNULL(u.firstname, '') AS firstname, IFNULL(u.lastname, '') as lastname, u.email, u.initials, u.password, u.salt, u.reset, u.created, u.revised
|
||||||
FROM user u LEFT JOIN account a ON u.refid = a.userid
|
FROM user u LEFT JOIN account a ON u.refid = a.userid
|
||||||
WHERE a.orgid=? AND a.active=1 AND u.refid IN (
|
WHERE a.orgid=? AND a.active=1 AND u.refid IN (
|
||||||
SELECT whoid from permission
|
SELECT whoid from permission
|
||||||
WHERE orgid=? AND who='user' AND location='category' AND refid=?
|
WHERE orgid=? AND who='user' AND location='category' AND refid=?
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT r.userid from rolemember r
|
SELECT r.userid from rolemember r
|
||||||
|
@ -283,7 +283,7 @@ func (s Scope) DeleteSpaceCategoryPermissions(ctx domain.RequestContext, spaceID
|
||||||
b := mysql.BaseQuery{}
|
b := mysql.BaseQuery{}
|
||||||
|
|
||||||
sql := fmt.Sprintf(`
|
sql := fmt.Sprintf(`
|
||||||
DELETE FROM permission WHERE orgid='%s' AND location='category'
|
DELETE FROM permission WHERE orgid='%s' AND location='category'
|
||||||
AND refid IN (SELECT refid FROM category WHERE orgid='%s' AND labelid='%s')`,
|
AND refid IN (SELECT refid FROM category WHERE orgid='%s' AND labelid='%s')`,
|
||||||
ctx.OrgID, ctx.OrgID, spaceID)
|
ctx.OrgID, ctx.OrgID, spaceID)
|
||||||
|
|
||||||
|
|
|
@ -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')();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ export default Component.extend(ModalMixin, TooltipMixin, AuthMixin, {
|
||||||
if (is.not.null(this.get('dropzone'))) {
|
if (is.not.null(this.get('dropzone'))) {
|
||||||
this.get('dropzone').destroy();
|
this.get('dropzone').destroy();
|
||||||
this.set('dropzone', null);
|
this.set('dropzone', null);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getDefaultInvitationMessage() {
|
getDefaultInvitationMessage() {
|
||||||
|
@ -354,7 +354,7 @@ export default Component.extend(ModalMixin, TooltipMixin, AuthMixin, {
|
||||||
let template = this.get('templates').findBy('id', id)
|
let template = this.get('templates').findBy('id', id)
|
||||||
|
|
||||||
this.modalClose("#space-template-modal");
|
this.modalClose("#space-template-modal");
|
||||||
|
|
||||||
let slug = stringUtil.makeSlug(template.get('title'));
|
let slug = stringUtil.makeSlug(template.get('title'));
|
||||||
this.get('router').transitionTo('document', this.get('space.id'), this.get('space.slug'), id, slug);
|
this.get('router').transitionTo('document', this.get('space.id'), this.get('space.slug'), id, slug);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{{#toolbar/t-toolbar}}
|
{{#toolbar/t-toolbar}}
|
||||||
|
|
||||||
{{#toolbar/t-links}}
|
{{#toolbar/t-links}}
|
||||||
{{#link-to "folders" class="link" tagName="li"}}Spaces{{/link-to}}
|
{{#link-to "folders" class="link" tagName="li"}}Spaces{{/link-to}}
|
||||||
{{/toolbar/t-links}}
|
{{/toolbar/t-links}}
|
||||||
|
@ -189,7 +189,7 @@
|
||||||
<div class="import-zone">
|
<div class="import-zone">
|
||||||
<button id="import-document-button" type="button" class="btn btn-outline-secondary btn-lg btn-block">
|
<button id="import-document-button" type="button" class="btn btn-outline-secondary btn-lg btn-block">
|
||||||
<br/>
|
<br/>
|
||||||
Click to select files or drag-drop files
|
Click to select files or drag-drop files
|
||||||
<br/><br/>
|
<br/><br/>
|
||||||
.doc, .docx, .md, .markdown
|
.doc, .docx, .md, .markdown
|
||||||
<br/><br/>
|
<br/><br/>
|
||||||
|
@ -206,10 +206,10 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/toolbar/t-actions}}
|
{{/toolbar/t-actions}}
|
||||||
|
|
||||||
{{/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