Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
portal-backend
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
HBP Medical Informatics Platform
portal-backend
Commits
fa69ac6e
Commit
fa69ac6e
authored
9 years ago
by
Mirco Nasuti
Browse files
Options
Downloads
Patches
Plain Diff
edit on someone else's article/model is now forbidden
parent
3baf316f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/org/hbp/mip/controllers/ArticlesApi.java
+18
-3
18 additions, 3 deletions
src/main/java/org/hbp/mip/controllers/ArticlesApi.java
src/main/java/org/hbp/mip/controllers/ModelsApi.java
+16
-3
16 additions, 3 deletions
src/main/java/org/hbp/mip/controllers/ModelsApi.java
with
34 additions
and
6 deletions
src/main/java/org/hbp/mip/controllers/ArticlesApi.java
+
18
−
3
View file @
fa69ac6e
...
...
@@ -45,7 +45,7 @@ public class ArticlesApi {
User
user
=
mipApplication
.
getUser
();
String
queryString
=
"SELECT a FROM Article a, User u WHERE a.createdBy=u.
id
"
;
String
queryString
=
"SELECT a FROM Article a, User u WHERE a.createdBy=u.
username
"
;
if
(
status
!=
null
)
{
queryString
+=
" AND status= :status"
;
...
...
@@ -58,7 +58,8 @@ public class ArticlesApi {
{
if
(
team
!=
null
&&
team
)
{
queryString
+=
" AND u.team= :team"
;
// TODO: decide if this is needed
//queryString += " AND u.team= :team";
}
}
...
...
@@ -74,7 +75,8 @@ public class ArticlesApi {
query
.
setString
(
"username"
,
user
.
getUsername
());
}
else
{
if
(
team
!=
null
&&
team
)
{
query
.
setString
(
"team"
,
user
.
getTeam
());
// TODO: decide if this is needed
//query.setString("team", user.getTeam());
}
}
articles
=
query
.
list
();
...
...
@@ -210,10 +212,23 @@ public class ArticlesApi {
@RequestBody
@ApiParam
(
value
=
"Article to update"
,
required
=
true
)
@Valid
Article
article
)
{
User
user
=
mipApplication
.
getUser
();
Session
session
=
HibernateUtil
.
getSessionFactory
().
getCurrentSession
();
try
{
session
.
beginTransaction
();
String
author
=
(
String
)
session
.
createQuery
(
"select U.username from User U, Article A where A.createdBy = U.username and A.slug = :slug"
)
.
setString
(
"slug"
,
slug
)
.
uniqueResult
();
if
(!
user
.
getUsername
().
equals
(
author
))
{
session
.
getTransaction
().
commit
();
return
new
ResponseEntity
<>(
HttpStatus
.
FORBIDDEN
);
}
String
oldTitle
=
(
String
)
session
.
createQuery
(
"select title from Article where slug= :slug"
)
.
setString
(
"slug"
,
slug
)
...
...
This diff is collapsed.
Click to expand it.
src/main/java/org/hbp/mip/controllers/ModelsApi.java
+
16
−
3
View file @
fa69ac6e
...
...
@@ -44,7 +44,7 @@ public class ModelsApi {
User
user
=
mipApplication
.
getUser
();
String
queryString
=
"SELECT m FROM Model m, User u WHERE m.createdBy=u.
id
"
;
String
queryString
=
"SELECT m FROM Model m, User u WHERE m.createdBy=u.
username
"
;
if
(
own
!=
null
&&
own
)
{
queryString
+=
" AND u.username= :username"
;
...
...
@@ -53,7 +53,8 @@ public class ModelsApi {
{
if
(
team
!=
null
&&
team
)
{
queryString
+=
" AND u.team= :team"
;
// TODO: decide if this is needed
//queryString += " AND u.team= :team";
}
}
...
...
@@ -70,7 +71,8 @@ public class ModelsApi {
{
if
(
team
!=
null
&&
team
)
{
query
.
setString
(
"team"
,
user
.
getTeam
());
// TODO: decide if this is needed
//query.setString("team", user.getTeam());
}
}
if
(
limit
!=
null
)
...
...
@@ -288,6 +290,17 @@ public class ModelsApi {
try
{
session
.
beginTransaction
();
String
author
=
(
String
)
session
.
createQuery
(
"select U.username from User U, Model M where M.createdBy = U.username and M.slug = :slug"
)
.
setString
(
"slug"
,
slug
)
.
uniqueResult
();
if
(!
user
.
getUsername
().
equals
(
author
))
{
session
.
getTransaction
().
commit
();
return
new
ResponseEntity
<>(
HttpStatus
.
FORBIDDEN
);
}
String
oldTitle
=
(
String
)
session
.
createQuery
(
"select title from Model where slug= :slug"
)
.
setString
(
"slug"
,
slug
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment