Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Project
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Coscine
backend
apis
Project
Merge requests
!68
Sprint/2020-02
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Sprint/2020-02
Product/441-createProjectPage
into
Sprint/2020-02
Overview
0
Commits
2
Pipelines
1
Changes
1
Merged
Marcel Nellesen
requested to merge
Product/441-createProjectPage
into
Sprint/2020-02
5 years ago
Overview
0
Commits
2
Pipelines
1
Changes
1
Expand
0
0
Merge request reports
Compare
Sprint/2020-02
Sprint/2020-02 (base)
and
latest version
latest version
b8cbeaf9
2 commits,
5 years ago
1 file
+
27
−
0
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
src/Project/Controllers/SubProjectController.cs
+
27
−
0
Options
@@ -2,6 +2,7 @@
@@ -2,6 +2,7 @@
using
Coscine.ApiCommons
;
using
Coscine.ApiCommons
;
using
Microsoft.AspNetCore.Authorization
;
using
Microsoft.AspNetCore.Authorization
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.AspNetCore.Mvc
;
using
Newtonsoft.Json.Linq
;
using
System
;
using
System
;
using
System.Linq
;
using
System.Linq
;
@@ -47,5 +48,31 @@ namespace Coscine.Api.Project.Controllers
@@ -47,5 +48,31 @@ namespace Coscine.Api.Project.Controllers
return
Unauthorized
(
"User is not allowed to create a subproject for the given project id!"
);
return
Unauthorized
(
"User is not allowed to create a subproject for the given project id!"
);
}
}
}
}
[
HttpGet
(
"[controller]/{childId}/accessibleParent"
)]
public
IActionResult
GetAccessibleParent
(
string
childId
)
{
var
childGuid
=
new
Guid
(
childId
);
var
projectModel
=
new
ProjectModel
();
var
projectRoleModel
=
new
ProjectRoleModel
();
var
user
=
_authenticator
.
GetUser
();
string
[]
allowedRoles
=
{
UserRoles
.
Owner
,
UserRoles
.
Member
};
allowedRoles
=
allowedRoles
.
Select
(
x
=>
x
.
ToLower
().
Trim
()).
ToArray
();
if
(
projectModel
.
HasAccess
(
user
,
projectModel
.
GetById
(
childGuid
),
allowedRoles
))
{
var
subProjects
=
_subProjectModel
.
GetAllWhere
((
subProjectM
)
=>
(
subProjectM
.
SubProjectId
==
childGuid
)).
ToArray
();
var
json
=
new
JObject
();
json
[
"id"
]
=
"00000000-0000-0000-0000-000000000000"
;
if
(
subProjects
.
Count
()
==
1
&&
projectModel
.
HasAccess
(
user
,
projectModel
.
GetById
(
subProjects
[
0
].
ProjectId
),
allowedRoles
))
{
json
[
"id"
]
=
subProjects
[
0
].
ProjectId
;
}
return
Json
(
json
);
}
else
{
return
Unauthorized
(
"User is not allowed to create a subproject for the given project id!"
);
}
}
}
}
}
}
Loading