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 Mobile
Project
Project
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
200
Issues
200
List
Boards
Labels
Service Desk
Milestones
Merge Requests
18
Merge Requests
18
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
Commits
Issue Boards
Open sidebar
Minds
Minds Mobile
Commits
661d4b54
Commit
661d4b54
authored
1 hour ago
by
Martin Santangelo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(feat) handle 403 responses on channels service
parent
623619db
feat/permissions-implementation-model-activitysheet-channels
1 merge request
!387
WIP: Permissions EPIC
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
3 deletions
+26
-3
src/common/services/channels.service.js
src/common/services/channels.service.js
+25
-2
src/common/services/entities.service.js
src/common/services/entities.service.js
+1
-1
No files found.
src/common/services/channels.service.js
View file @
661d4b54
import
apiService
from
"
./api.service
"
;
import
apiService
,
{
isApiForbidden
}
from
"
./api.service
"
;
import
UserModel
from
"
../../channel/UserModel
"
;
import
{
abort
}
from
"
../helpers/abortableFetch
"
;
...
...
@@ -42,6 +42,7 @@ class ChannelsService {
if
(
response
.
channel
)
{
const
urn
=
`urn:channels:
${
guid
}
`
;
if
(
channel
)
{
channel
.
update
(
response
.
channel
);
}
else
{
...
...
@@ -55,16 +56,38 @@ class ChannelsService {
throw
new
Error
(
'
No channel response
'
);
}
}
catch
(
err
)
{
console
.
log
(
err
)
// if the server response is a 403
if
(
isApiForbidden
(
err
))
{
// remove the permissions to force the UI update\
if
(
channel
)
{
channel
.
setPermissions
({
permissions
:[]});
}
// remove it from local storage
this
.
removeFromCache
(
channel
);
return
;
}
throw
err
;
}
}
/**
* Save to cache
* @param {UserModel} channel
*/
async
save
(
channel
)
{
// add urn to channel
channel
.
urn
=
`urn:channels:
${
channel
.
guid
}
`
;
entitiesStorage
.
save
(
channel
);
}
/**
* Remove from cache
* @param {UserModel} channel
*/
removeFromCache
(
channel
)
{
const
urn
=
`urn:channels:
${
channel
.
guid
}
`
;
entitiesStorage
.
remove
(
urn
);
}
}
export
default
new
ChannelsService
();
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/common/services/entities.service.js
View file @
661d4b54
// @flow
import
_
from
'
lodash
'
;
import
apiService
,
{
isApiForbidden
,
ApiError
}
from
"
./api.service
"
;
import
apiService
,
{
isApiForbidden
}
from
"
./api.service
"
;
import
sessionService
from
"
./session.service
"
;
import
blockListService
from
"
./block-list.service
"
;
import
GroupModel
from
"
../../groups/GroupModel
"
;
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment