Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue 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
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
516f52f4
Commit
516f52f4
authored
9 years ago
by
Allen Gilliland
Browse files
Options
Downloads
Plain Diff
Merge pull request #491 from metabase/fix_grant_revoke_admin
Fix grant/revoke admin
parents
5d462aad
b3dcd295
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/metabase/api/user.clj
+5
-2
5 additions, 2 deletions
src/metabase/api/user.clj
test/metabase/api/user_test.clj
+7
-0
7 additions, 0 deletions
test/metabase/api/user_test.clj
with
12 additions
and
2 deletions
src/metabase/api/user.clj
+
5
−
2
View file @
516f52f4
...
...
@@ -51,7 +51,7 @@
(
defendpoint
PUT
"/:id"
"Update a `User`."
[
id
:as
{{
:keys
[
email
first_name
last_name
]
:as
body
}
:body
}]
[
id
:as
{{
:keys
[
email
first_name
last_name
is_superuser
]
:as
body
}
:body
}]
{
email
[
Required
Email
]
first_name
NonEmptyString
last_name
NonEmptyString
}
...
...
@@ -61,7 +61,10 @@
(
check-500
(
upd-non-nil-keys
User
id
:email
email
:first_name
first_name
:last_name
last_name
))
:last_name
last_name
:is_superuser
(
if
(
:is_superuser
@
*current-user*
)
is_superuser
nil
)))
(
sel
:one
User
:id
id
))
...
...
This diff is collapsed.
Click to expand it.
test/metabase/api/user_test.clj
+
7
−
0
View file @
516f52f4
...
...
@@ -174,6 +174,13 @@
:email
new-email
})
(
fetch-user
))])
;; Test that a normal user cannot change the :is_superuser flag for themselves
(
expect-let
[
fetch-user
(
fn
[]
(
sel
:one
:fields
[
User
:first_name
:last_name
:is_superuser
:email
]
:id
(
user->id
:rasta
)))]
[(
fetch-user
)]
[(
do
((
user->client
:rasta
)
:put
200
(
str
"user/"
(
user->id
:rasta
))
(
->
(
fetch-user
)
(
assoc
:is_superuser
true
)))
(
fetch-user
))])
;; Check that a non-superuser CANNOT update someone else's user details
(
expect
"You don't have permissions to do that."
((
user->client
:rasta
)
:put
403
(
str
"user/"
(
user->id
:trashbird
))
{
:email
"toucan@metabase.com"
}))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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