Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
archery
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
3
Issues
3
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
archery
Commits
a6670b98
Commit
a6670b98
authored
Oct 10, 2014
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved user access checks
parent
ca355adb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
15 deletions
+15
-15
routes/user.php
routes/user.php
+15
-5
util.php
util.php
+0
-10
No files found.
routes/user.php
View file @
a6670b98
...
...
@@ -5,9 +5,20 @@ use Instante\Bootstrap3Renderer\BootstrapRenderer;
use
Nette\Security\Passwords
;
function
find_user
(
$id
)
{
global
$db
;
require_user_access
(
$id
);
return
$db
->
table
(
'user'
)
->
get
(
$id
);
global
$app
,
$db
,
$user
;
if
(
!
$user
->
isLoggedIn
())
$app
->
redirect
(
ROOT_URL
.
'/login'
);
if
(
$user
->
getId
()
!=
$id
&&
!
in_array
(
'admin'
,
$user
->
getRoles
()))
$app
->
halt
(
403
,
_
(
'No access to this user'
));
$dbuser
=
$db
->
table
(
'user'
)
->
get
(
$id
);
if
(
!
$dbuser
)
$app
->
halt
(
403
,
_
(
'User not found'
));
return
$dbuser
;
}
function
edit_user_form
(
$dbuser
)
{
...
...
@@ -114,8 +125,7 @@ function plot_filter_form($dbuser, $matches, $default_discipline) {
}
$app
->
get
(
'/user/:id/plot'
,
function
(
$id
)
use
(
$app
,
$db
,
$user
)
{
require_user_access
(
$id
);
$dbuser
=
$db
->
table
(
'user'
)
->
get
(
$user
->
getId
());
$dbuser
=
find_user
(
$id
);
$matches
=
$db
->
table
(
'match'
)
->
where
(
array
(
'user_id'
=>
$id
))
...
...
util.php
View file @
a6670b98
...
...
@@ -45,16 +45,6 @@ function set_accept_locale($supported_languages=null) {
return
null
;
}
function
require_user_access
(
$user_id
)
{
global
$user
,
$app
;
if
(
!
$user
->
isLoggedIn
())
$app
->
redirect
(
ROOT_URL
.
'/login'
);
if
(
$user
->
getId
()
!=
$user_id
&&
!
in_array
(
'admin'
,
$user
->
getRoles
()))
$app
->
halt
(
403
,
_
(
'No access to this user'
));
}
function
find_match
(
$id
)
{
global
$app
,
$db
,
$user
;
$match
=
$db
->
table
(
'match'
)
->
get
(
$id
);
...
...
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