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
864
Issues
864
List
Boards
Labels
Service Desk
Milestones
Merge Requests
47
Merge Requests
47
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
cab480ddf367b21ac811e00574cbe01301c97525...533e999a6157963d3cbfb4d49b48164e66745f6e
Source
533e999a6157963d3cbfb4d49b48164e66745f6e
Select Git revision
...
Target
cab480ddf367b21ac811e00574cbe01301c97525
Select Git revision
Compare
Commits (3)
(feat): enforce create_group permission
· 2fff24a1
Marcelo Rivera
authored
2 days ago
2fff24a1
(fix): update PermissionsService based on new permissions export
· d6fad37e
Marcelo Rivera
authored
54 minutes ago
d6fad37e
(feat): moved PermissionsService to its own folder and added Flags enum
· 533e999a
Marcelo Rivera
authored
6 minutes ago
533e999a
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
106 additions
and
18 deletions
+106
-18
post-menu.component.ts
src/app/common/components/post-menu/post-menu.component.ts
+7
-3
flags.ts
src/app/common/services/permissions/flags.ts
+26
-0
permissions.service.ts
src/app/common/services/permissions/permissions.service.ts
+7
-2
channel.component.ts
src/app/modules/channels/channel.component.ts
+1
-1
comment.component.ts
src/app/modules/comments/comment/comment.component.ts
+7
-3
thread.component.ts
src/app/modules/comments/thread/thread.component.ts
+3
-2
can-create-group-guard.service.ts
...p/modules/groups/create/can-create-group-guard.service.ts
+35
-0
groups.module.ts
src/app/modules/groups/groups.module.ts
+7
-2
groups-settings-button.ts
src/app/modules/groups/profile/groups-settings-button.ts
+6
-2
remind.ts
src/app/modules/legacy/components/buttons/remind.ts
+6
-2
providers.ts
src/app/services/providers.ts
+1
-1
No files found.
src/app/common/components/post-menu/post-menu.component.ts
View file @
533e999a
...
...
@@ -15,7 +15,8 @@ import { BlockListService } from '../../services/block-list.service';
import
{
ActivityService
}
from
'
../../../common/services/activity.service
'
;
import
{
FeaturesService
}
from
'
../../../services/features.service
'
;
import
{
ShareModalComponent
}
from
'
../../../modules/modals/share/share
'
;
import
{
PermissionsService
}
from
'
../../services/permissions.service
'
;
import
{
PermissionsService
}
from
'
../../services/permissions/permissions.service
'
;
import
{
Flags
}
from
'
../../services/permissions/flags
'
;
type
Option
=
|
'
edit
'
...
...
@@ -372,7 +373,7 @@ export class PostMenuComponent {
checkEditPermissions
()
{
if
(
this
.
featuresService
.
has
(
'
permissions
'
))
{
return
this
.
permissionsService
.
canInteract
(
this
.
entity
,
'
edit_post
'
);
return
this
.
permissionsService
.
canInteract
(
this
.
entity
,
Flags
.
EDIT_POST
);
}
return
(
...
...
@@ -383,7 +384,10 @@ export class PostMenuComponent {
checkDeletePermissions
()
{
if
(
this
.
featuresService
.
has
(
'
permissions
'
))
{
return
this
.
permissionsService
.
canInteract
(
this
.
entity
,
'
delete_post
'
);
return
this
.
permissionsService
.
canInteract
(
this
.
entity
,
Flags
.
DELETE_POST
);
}
return
(
...
...
This diff is collapsed.
Click to expand it.
src/app/common/services/permissions/flags.ts
0 → 100644
View file @
533e999a
export
enum
Flags
{
APPOINT_ADMIN
=
'
appoint_admin
'
,
APPOINT_MODERATOR
=
'
appoint_moderator
'
,
APPROVE_SUBSCRIBER
=
'
approve_subscriber
'
,
CREATE_CHANNEL
=
'
create_channel
'
,
CREATE_COMMENT
=
'
create_comment
'
,
CREATE_GROUP
=
'
create_group
'
,
CREATE_POST
=
'
create_post
'
,
DELETE_CHANNEL
=
'
delete_channel
'
,
DELETE_COMMENT
=
'
delete_comment
'
,
DELETE_GROUP
=
'
delete_group
'
,
DELETE_POST
=
'
delete_post
'
,
EDIT_CHANNEL
=
'
edit_channel
'
,
EDIT_COMMENT
=
'
edit_comment
'
,
EDIT_GROUP
=
'
edit_group
'
,
EDIT_POST
=
'
edit_post
'
,
INVITE
=
'
invite
'
,
JOIN
=
'
join
'
,
JOIN_GATHERING
=
'
gathering
'
,
MESSAGE
=
'
message
'
,
SUBSCRIBE
=
'
subscribe
'
,
TAG
=
'
tag
'
,
REMIND
=
'
remind
'
,
VIEW
=
'
wire
'
,
VOTE
=
'
vote
'
,
}
This diff is collapsed.
Click to expand it.
src/app/common/services/permissions.service.ts
→
src/app/common/services/permissions
/permissions
.service.ts
View file @
533e999a
import
{
Flags
}
from
'
./flags
'
;
export
type
Permissions
=
{
name
:
string
;
permissions
:
string
[];
};
export
class
PermissionsService
{
canInteract
(
entity
:
any
,
permission
:
string
)
{
canInteract
(
entity
:
any
,
permission
:
Flags
)
{
let
permissions
:
Permissions
=
entity
.
permissions
;
if
(
!
permissions
)
{
return
false
;
}
return
(
permissions
&&
permissions
.
permissions
.
findIndex
(
item
=>
item
===
permission
)
!==
-
1
);
}
...
...
This diff is collapsed.
Click to expand it.
src/app/modules/channels/channel.component.ts
View file @
533e999a
...
...
@@ -17,7 +17,7 @@ import { Observable } from 'rxjs';
import
{
DialogService
}
from
'
../../common/services/confirm-leave-dialog.service
'
;
import
{
BlockListService
}
from
'
../../common/services/block-list.service
'
;
import
{
ChannelSortedComponent
}
from
'
./sorted/sorted.component
'
;
import
{
PermissionsService
}
from
'
../../common/services/permissions.service
'
;
import
{
PermissionsService
}
from
'
../../common/services/permissions
/permissions
.service
'
;
import
{
ClientMetaService
}
from
'
../../common/services/client-meta.service
'
;
@
Component
({
...
...
This diff is collapsed.
Click to expand it.
src/app/modules/comments/comment/comment.component.ts
View file @
533e999a
...
...
@@ -32,7 +32,8 @@ import { FeaturesService } from '../../../services/features.service';
import
{
MindsVideoComponent
}
from
'
../../media/components/video/video.component
'
;
import
{
MediaModalComponent
}
from
'
../../media/modal/modal.component
'
;
import
isMobile
from
'
../../../helpers/is-mobile
'
;
import
{
PermissionsService
}
from
'
../../../common/services/permissions.service
'
;
import
{
PermissionsService
}
from
'
../../../common/services/permissions/permissions.service
'
;
import
{
Flags
}
from
'
../../../common/services/permissions/flags
'
;
@
Component
({
selector
:
'
m-comment
'
,
...
...
@@ -385,7 +386,10 @@ export class CommentComponentV2
checkEditPermissions
()
{
if
(
this
.
featuresService
.
has
(
'
permissions
'
))
{
return
this
.
permissionsService
.
canInteract
(
this
.
comment
,
'
edit_comment
'
);
return
this
.
permissionsService
.
canInteract
(
this
.
comment
,
Flags
.
EDIT_COMMENT
);
}
return
(
...
...
@@ -399,7 +403,7 @@ export class CommentComponentV2
if
(
this
.
featuresService
.
has
(
'
permissions
'
))
{
return
this
.
permissionsService
.
canInteract
(
this
.
comment
,
'
delete_comment
'
Flags
.
DELETE_COMMENT
);
}
...
...
This diff is collapsed.
Click to expand it.
src/app/modules/comments/thread/thread.component.ts
View file @
533e999a
...
...
@@ -24,7 +24,8 @@ import { ActivityService } from '../../../common/services/activity.service';
import
{
Subscription
}
from
'
rxjs
'
;
import
{
TouchSequence
}
from
'
selenium-webdriver
'
;
import
{
FeaturesService
}
from
'
../../../services/features.service
'
;
import
{
PermissionsService
}
from
'
../../../common/services/permissions.service
'
;
import
{
PermissionsService
}
from
'
../../../common/services/permissions/permissions.service
'
;
import
{
Flags
}
from
'
../../../common/services/permissions/flags
'
;
@
Component
({
selector
:
'
m-comments__thread
'
,
...
...
@@ -94,7 +95,7 @@ export class CommentsThreadComponent implements OnInit {
// TODO: maybe there should be a "view comment" flag?
this
.
canPost
=
await
this
.
permissionsService
.
canInteract
(
this
.
entity
,
'
create_comment
'
Flags
.
CREATE_COMMENT
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/app/modules/groups/create/can-create-group-guard.service.ts
0 → 100644
View file @
533e999a
import
{
Injectable
}
from
'
@angular/core
'
;
import
{
ActivatedRouteSnapshot
,
CanActivate
,
Router
,
RouterStateSnapshot
,
}
from
'
@angular/router
'
;
import
{
FeaturesService
}
from
'
../../../services/features.service
'
;
import
{
PermissionsService
}
from
'
../../../common/services/permissions/permissions.service
'
;
import
{
Session
}
from
'
../../../services/session
'
;
import
{
Flags
}
from
'
../../../common/services/permissions/flags
'
;
@
Injectable
()
export
class
CanCreateGroupGuardService
implements
CanActivate
{
constructor
(
private
router
:
Router
,
private
featuresService
:
FeaturesService
,
private
permissionsService
:
PermissionsService
,
private
session
:
Session
)
{}
canActivate
(
route
:
ActivatedRouteSnapshot
,
state
:
RouterStateSnapshot
)
{
if
(
!
this
.
session
.
getLoggedInUser
())
{
this
.
router
.
navigate
([
'
/login
'
]);
return
false
;
}
if
(
this
.
featuresService
.
has
(
'
permissions
'
))
{
return
this
.
permissionsService
.
canInteract
(
this
.
session
.
getLoggedInUser
(),
Flags
.
CREATE_GROUP
);
}
return
true
;
}
}
This diff is collapsed.
Click to expand it.
src/app/modules/groups/groups.module.ts
View file @
533e999a
...
...
@@ -38,6 +38,7 @@ import { NewsfeedModule } from '../newsfeed/newsfeed.module';
import
{
GroupsProfileReviewComponent
}
from
'
./profile/review/review.component
'
;
import
{
GroupsKickModalComponent
}
from
'
./kick-modal/kick-modal.component
'
;
import
{
TextInputAutocompleteModule
}
from
'
../../common/components/autocomplete
'
;
import
{
CanCreateGroupGuardService
}
from
'
./create/can-create-group-guard.service
'
;
const
routes
:
Routes
=
[
{
...
...
@@ -54,7 +55,11 @@ const routes: Routes = [
{
path
:
'
requests
'
,
component
:
GroupsProfileRequests
},
],
},
{
path
:
'
groups/create
'
,
component
:
GroupsCreator
},
{
path
:
'
groups/create
'
,
component
:
GroupsCreator
,
canActivate
:
[
CanCreateGroupGuardService
],
},
{
path
:
'
groups/:filter
'
,
component
:
GroupsListComponent
},
{
path
:
'
groups
'
,
redirectTo
:
'
/groups/top
'
,
pathMatch
:
'
full
'
},
];
...
...
@@ -117,6 +122,6 @@ const routes: Routes = [
GroupsSidebarMarkersComponent
,
],
entryComponents
:
[
GroupsCard
,
GroupsSidebarMarkersComponent
],
providers
:
[
CanDeactivateGroupService
],
providers
:
[
Can
CreateGroupGuardService
,
Can
DeactivateGroupService
],
})
export
class
GroupsModule
{}
This diff is collapsed.
Click to expand it.
src/app/modules/groups/profile/groups-settings-button.ts
View file @
533e999a
...
...
@@ -7,7 +7,8 @@ import { OverlayModalService } from '../../../services/ux/overlay-modal';
import
{
Client
}
from
'
../../../services/api/client
'
;
import
{
Session
}
from
'
../../../services/session
'
;
import
{
FeaturesService
}
from
'
../../../services/features.service
'
;
import
{
PermissionsService
}
from
'
../../../common/services/permissions.service
'
;
import
{
PermissionsService
}
from
'
../../../common/services/permissions/permissions.service
'
;
import
{
Flags
}
from
'
../../../common/services/permissions/flags
'
;
@
Component
({
selector
:
'
minds-groups-settings-button
'
,
...
...
@@ -311,7 +312,10 @@ export class GroupsSettingsButton {
checkDeletePermissions
()
{
if
(
this
.
featuresService
.
has
(
'
permissions
'
))
{
return
this
.
permissionsService
.
canInteract
(
this
.
group
,
'
delete_group
'
);
return
this
.
permissionsService
.
canInteract
(
this
.
group
,
Flags
.
DELETE_GROUP
);
}
return
true
;
...
...
This diff is collapsed.
Click to expand it.
src/app/modules/legacy/components/buttons/remind.ts
View file @
533e999a
...
...
@@ -3,8 +3,9 @@ import { Component, ChangeDetectionStrategy, Input } from '@angular/core';
import
{
Session
}
from
'
../../../../services/session
'
;
import
{
Client
}
from
'
../../../../services/api
'
;
import
{
SignupModalService
}
from
'
../../../../modules/modals/signup/service
'
;
import
{
PermissionsService
}
from
'
../../../../common/services/permissions.service
'
;
import
{
PermissionsService
}
from
'
../../../../common/services/permissions
/permissions
.service
'
;
import
{
FeaturesService
}
from
'
../../../../services/features.service
'
;
import
{
Flags
}
from
'
../../../../common/services/permissions/flags
'
;
// had forwardRef(() => RemindComposerModal)
@
Component
({
...
...
@@ -55,7 +56,10 @@ export class RemindButton {
private
checkPermissions
()
{
if
(
this
.
featuresService
.
has
(
'
permissions
'
))
{
this
.
enabled
=
this
.
permissionsService
.
canInteract
(
this
.
object
,
'
remind
'
);
this
.
enabled
=
this
.
permissionsService
.
canInteract
(
this
.
object
,
Flags
.
REMIND
);
}
else
{
this
.
enabled
=
true
;
}
...
...
This diff is collapsed.
Click to expand it.
src/app/services/providers.ts
View file @
533e999a
...
...
@@ -46,7 +46,7 @@ import { AuthService } from './auth.service';
import
{
SiteService
}
from
'
../common/services/site.service
'
;
import
{
SessionsStorageService
}
from
'
./session-storage.service
'
;
import
{
DiagnosticsService
}
from
'
./diagnostics.service
'
;
import
{
PermissionsService
}
from
'
../common/services/permissions.service
'
;
import
{
PermissionsService
}
from
'
../common/services/permissions
/permissions
.service
'
;
export
const
MINDS_PROVIDERS
:
any
[]
=
[
SiteService
,
...
...
This diff is collapsed.
Click to expand it.