Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Minds Frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
870
Issues
870
List
Boards
Labels
Service Desk
Milestones
Merge Requests
46
Merge Requests
46
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Security & Compliance
Security & Compliance
Dependency List
Packages
Packages
List
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Frontend
Compare Revisions
9ace96a7ab2c384059dea146192f70478d36d349...4eb519c4fff6f57089ae0a78be674e9d945a2a29
Source
4eb519c4fff6f57089ae0a78be674e9d945a2a29
Select Git revision
...
Target
9ace96a7ab2c384059dea146192f70478d36d349
Select Git revision
Compare
Commits (3)
(feat): enforce edit_post and delete_post for activities, blogs
· 3dd7a390
Marcelo Rivera
authored
1 hour ago
3dd7a390
(fix): add return types
· 81f67f0a
Marcelo Rivera
authored
15 minutes ago
81f67f0a
(fix): spacing
· 4eb519c4
Marcelo Rivera
authored
15 minutes ago
4eb519c4
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
69 additions
and
26 deletions
+69
-26
src/app/common/components/post-menu/post-menu.component.ts
src/app/common/components/post-menu/post-menu.component.ts
+2
-2
src/app/common/services/permissions/permissions.service.ts
src/app/common/services/permissions/permissions.service.ts
+2
-2
src/app/modules/blogs/view/view.spec.ts
src/app/modules/blogs/view/view.spec.ts
+10
-0
src/app/modules/blogs/view/view.ts
src/app/modules/blogs/view/view.ts
+19
-1
src/app/modules/comments/comment/comment.component.ts
src/app/modules/comments/comment/comment.component.ts
+2
-2
src/app/modules/groups/profile/groups-settings-button.ts
src/app/modules/groups/profile/groups-settings-button.ts
+1
-1
src/app/modules/legacy/components/cards/activity/activity.ts
src/app/modules/legacy/components/cards/activity/activity.ts
+19
-4
src/index.php
src/index.php
+14
-14
No files found.
src/app/common/components/post-menu/post-menu.component.ts
View file @
4eb519c4
...
...
@@ -371,7 +371,7 @@ export class PostMenuComponent {
this
.
selectOption
(
'
share
'
);
}
checkEditPermissions
()
{
checkEditPermissions
()
:
boolean
{
if
(
this
.
featuresService
.
has
(
'
permissions
'
))
{
return
this
.
permissionsService
.
canInteract
(
this
.
entity
,
Flags
.
EDIT_POST
);
}
...
...
@@ -382,7 +382,7 @@ export class PostMenuComponent {
);
}
checkDeletePermissions
()
{
checkDeletePermissions
()
:
boolean
{
if
(
this
.
featuresService
.
has
(
'
permissions
'
))
{
return
this
.
permissionsService
.
canInteract
(
this
.
entity
,
...
...
This diff is collapsed.
Click to expand it.
src/app/common/services/permissions/permissions.service.ts
View file @
4eb519c4
...
...
@@ -6,8 +6,8 @@ export type Permissions = {
};
export
class
PermissionsService
{
canInteract
(
entity
:
any
,
permission
:
Flags
)
{
le
t
permissions
:
Permissions
=
entity
.
permissions
;
canInteract
(
entity
:
any
,
permission
:
Flags
)
:
boolean
{
cons
t
permissions
:
Permissions
=
entity
.
permissions
;
if
(
!
permissions
)
{
return
false
;
...
...
This diff is collapsed.
Click to expand it.
src/app/modules/blogs/view/view.spec.ts
View file @
4eb519c4
...
...
@@ -30,6 +30,10 @@ import { AnalyticsService } from '../../../services/analytics';
import
{
analyticsServiceMock
}
from
'
../../../../tests/analytics-service-mock.spec
'
;
import
{
ActivityService
}
from
'
../../../common/services/activity.service
'
;
import
{
activityServiceMock
}
from
'
../../../../tests/activity-service-mock.spec
'
;
import
{
FeaturesService
}
from
'
../../../services/features.service
'
;
import
{
featuresServiceMock
}
from
'
../../../../tests/features-service-mock.spec
'
;
import
{
PermissionsService
}
from
'
../../../common/services/permissions/permissions.service
'
;
import
{
MockService
}
from
'
../../../utils/mock
'
;
describe
(
'
Blog view component
'
,
()
=>
{
let
comp
:
BlogView
;
...
...
@@ -55,6 +59,11 @@ describe('Blog view component', () => {
{
provide
:
MindsTitle
,
useValue
:
mindsTitleMock
},
{
provide
:
ScrollService
,
useValue
:
scrollServiceMock
},
{
provide
:
Session
,
useValue
:
sessionMock
},
{
provide
:
FeaturesService
,
useValue
:
featuresServiceMock
},
{
provide
:
PermissionsService
,
useValue
:
MockService
(
PermissionsService
),
},
],
schemas
:
[
NO_ERRORS_SCHEMA
],
})
...
...
@@ -64,6 +73,7 @@ describe('Blog view component', () => {
// synchronous beforeEach
beforeEach
(()
=>
{
featuresServiceMock
.
mock
(
'
permissions
'
,
false
);
fixture
=
TestBed
.
createComponent
(
BlogView
);
comp
=
fixture
.
componentInstance
;
comp
.
blog
=
blog
;
...
...
This diff is collapsed.
Click to expand it.
src/app/modules/blogs/view/view.ts
View file @
4eb519c4
...
...
@@ -23,8 +23,11 @@ import { ContextService } from '../../../services/context.service';
import
{
optimizedResize
}
from
'
../../../utils/optimized-resize
'
;
import
{
OverlayModalService
}
from
'
../../../services/ux/overlay-modal
'
;
import
{
ActivityService
}
from
'
../../../common/services/activity.service
'
;
import
{
ShareModalComponent
}
from
'
../../
../modules/
modals/share/share
'
;
import
{
ShareModalComponent
}
from
'
../../modals/share/share
'
;
import
{
ClientMetaService
}
from
'
../../../common/services/client-meta.service
'
;
import
{
Flags
}
from
'
../../../common/services/permissions/flags
'
;
import
{
FeaturesService
}
from
'
../../../services/features.service
'
;
import
{
PermissionsService
}
from
'
../../../common/services/permissions/permissions.service
'
;
@
Component
({
moduleId
:
module
.
id
,
...
...
@@ -103,6 +106,8 @@ export class BlogView implements OnInit, OnDestroy {
private
cd
:
ChangeDetectorRef
,
private
overlayModal
:
OverlayModalService
,
private
clientMetaService
:
ClientMetaService
,
private
featuresService
:
FeaturesService
,
private
permissionsService
:
PermissionsService
,
@
SkipSelf
()
injector
:
Injector
)
{
this
.
clientMetaService
...
...
@@ -154,6 +159,13 @@ export class BlogView implements OnInit, OnDestroy {
}
delete
()
{
if
(
this
.
featuresService
.
has
(
'
permissions
'
)
&&
!
this
.
permissionsService
.
canInteract
(
this
.
blog
,
Flags
.
EDIT_POST
)
)
{
return
;
}
this
.
client
.
delete
(
'
api/v1/blog/
'
+
this
.
blog
.
guid
)
.
then
((
response
:
any
)
=>
{
...
...
@@ -170,6 +182,12 @@ export class BlogView implements OnInit, OnDestroy {
menuOptionSelected
(
option
:
string
)
{
switch
(
option
)
{
case
'
edit
'
:
if
(
this
.
featuresService
.
has
(
'
permissions
'
)
&&
!
this
.
permissionsService
.
canInteract
(
this
.
blog
,
Flags
.
EDIT_POST
)
)
{
return
;
}
this
.
router
.
navigate
([
'
/blog/edit
'
,
this
.
blog
.
guid
]);
break
;
case
'
delete
'
:
...
...
This diff is collapsed.
Click to expand it.
src/app/modules/comments/comment/comment.component.ts
View file @
4eb519c4
...
...
@@ -384,7 +384,7 @@ export class CommentComponentV2
.
present
();
}
checkEditPermissions
()
{
checkEditPermissions
()
:
boolean
{
if
(
this
.
featuresService
.
has
(
'
permissions
'
))
{
return
this
.
permissionsService
.
canInteract
(
this
.
comment
,
...
...
@@ -399,7 +399,7 @@ export class CommentComponentV2
);
}
checkDeletePermissions
()
{
checkDeletePermissions
()
:
boolean
{
if
(
this
.
featuresService
.
has
(
'
permissions
'
))
{
return
this
.
permissionsService
.
canInteract
(
this
.
comment
,
...
...
This diff is collapsed.
Click to expand it.
src/app/modules/groups/profile/groups-settings-button.ts
View file @
4eb519c4
...
...
@@ -310,7 +310,7 @@ export class GroupsSettingsButton {
this
.
overlayService
.
create
(
ReportCreatorComponent
,
this
.
group
).
present
();
}
checkDeletePermissions
()
{
checkDeletePermissions
()
:
boolean
{
if
(
this
.
featuresService
.
has
(
'
permissions
'
))
{
return
this
.
permissionsService
.
canInteract
(
this
.
group
,
...
...
This diff is collapsed.
Click to expand it.
src/app/modules/legacy/components/cards/activity/activity.ts
View file @
4eb519c4
import
{
Component
,
ChangeDetectionStrategy
,
ChangeDetectorRef
,
EventEmitter
,
Component
,
ElementRef
,
EventEmitter
,
Injector
,
Input
,
ViewChild
,
OnInit
,
SkipSelf
,
Injector
,
ViewChild
,
}
from
'
@angular/core
'
;
import
{
Client
}
from
'
../../../../../services/api
'
;
...
...
@@ -30,6 +30,8 @@ import { AutocompleteSuggestionsService } from '../../../../suggestions/services
import
{
ActivityService
}
from
'
../../../../../common/services/activity.service
'
;
import
{
FeaturesService
}
from
'
../../../../../services/features.service
'
;
import
isMobile
from
'
../../../../../helpers/is-mobile
'
;
import
{
PermissionsService
}
from
'
../../../../../common/services/permissions/permissions.service
'
;
import
{
Flags
}
from
'
../../../../../common/services/permissions/flags
'
;
@
Component
({
moduleId
:
module
.
id
,
...
...
@@ -174,6 +176,7 @@ export class Activity implements OnInit {
protected
featuresService
:
FeaturesService
,
public
suggestions
:
AutocompleteSuggestionsService
,
protected
activityService
:
ActivityService
,
protected
permissionsService
:
PermissionsService
,
@
SkipSelf
()
injector
:
Injector
,
elementRef
:
ElementRef
)
{
...
...
@@ -273,6 +276,12 @@ export class Activity implements OnInit {
}
delete
(
$event
:
any
=
{})
{
if
(
this
.
featuresService
.
has
(
'
permissions
'
)
&&
!
this
.
permissionsService
.
canInteract
(
this
.
activity
,
Flags
.
DELETE_POST
)
)
{
return
;
}
if
(
$event
.
inProgress
)
{
$event
.
inProgress
.
emit
(
true
);
}
...
...
@@ -408,6 +417,12 @@ export class Activity implements OnInit {
this
.
router
.
navigate
([
'
/newsfeed
'
,
this
.
activity
.
guid
]);
break
;
case
'
edit
'
:
if
(
this
.
featuresService
.
has
(
'
permissions
'
)
&&
!
this
.
permissionsService
.
canInteract
(
this
.
activity
,
Flags
.
EDIT_POST
)
)
{
return
;
}
this
.
editing
=
true
;
break
;
case
'
delete
'
:
...
...
This diff is collapsed.
Click to expand it.
src/index.php
View file @
4eb519c4
...
...
@@ -147,20 +147,20 @@
];
if
(
Minds\Core\Session
::
isLoggedIn
())
{
$user
=
Minds\Core\Session
::
getLoggedinUser
();
$minds
[
'user'
]
=
$user
->
export
();
$minds
[
'user'
][
'rewards'
]
=
!!
Minds\Core\Session
::
getLoggedinUser
()
->
getPhoneNumberHash
();
$minds
[
'wallet'
]
=
array
(
'balance'
=>
Minds\Helpers\Counters
::
get
(
Minds\Core\Session
::
getLoggedinUser
()
->
guid
,
'points'
,
false
));
if
(
Minds\Core\Di\Di
::
_
()
->
get
(
'Features\Manager'
)
->
has
(
'permissions'
))
{
/** @var Minds\Core\Permissions\Manager $permissionsManager */
$permissionsManager
=
Minds\Core\Di\Di
::
_
()
->
get
(
'Permissions\Manager'
);
$permissions
=
$permissionsManager
->
getList
([
'user_guid'
=>
$user
,
'entities'
=>
[
$user
],
]);
$minds
[
'user'
][
'permissions'
]
=
$permissions
->
exportPermission
(
$user
->
getGuid
());
}
$user
=
Minds\Core\Session
::
getLoggedinUser
();
$minds
[
'user'
]
=
$user
->
export
();
$minds
[
'user'
][
'rewards'
]
=
!!
Minds\Core\Session
::
getLoggedinUser
()
->
getPhoneNumberHash
();
$minds
[
'wallet'
]
=
array
(
'balance'
=>
Minds\Helpers\Counters
::
get
(
Minds\Core\Session
::
getLoggedinUser
()
->
guid
,
'points'
,
false
));
if
(
Minds\Core\Di\Di
::
_
()
->
get
(
'Features\Manager'
)
->
has
(
'permissions'
))
{
/** @var Minds\Core\Permissions\Manager $permissionsManager */
$permissionsManager
=
Minds\Core\Di\Di
::
_
()
->
get
(
'Permissions\Manager'
);
$permissions
=
$permissionsManager
->
getList
([
'user_guid'
=>
$user
,
'entities'
=>
[
$user
],
]);
$minds
[
'user'
][
'permissions'
]
=
$permissions
->
exportPermission
(
$user
->
getGuid
());
}
}
if
(
__MINDS_CONTEXT__
===
'embed'
)
{
...
...
This diff is collapsed.
Click to expand it.