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
07031e1a
Commit
07031e1a
authored
10 years ago
by
Allen Gilliland
Browse files
Options
Downloads
Patches
Plain Diff
couple updates to streamline user updates endpoints.
parent
8a9bf0dc
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/metabase/api/user.clj
+10
-7
10 additions, 7 deletions
src/metabase/api/user.clj
with
10 additions
and
7 deletions
src/metabase/api/user.clj
+
10
−
7
View file @
07031e1a
...
...
@@ -26,21 +26,24 @@
(
defendpoint
PUT
"/:id"
[
id
:as
{
:keys
[
body
]}]
(
check-403
(
=
id
*current-user-id*
))
; you can only update yourself (or can admins update other users?)
; user must be getting their own details OR they must be a superuser to proceed
(
check-403
(
or
(
=
id
*current-user-id*
)
(
:is_superuser
@
*current-user*
)))
;; TODO - validate that email address isn't taken
(
check-500
(
->>
(
select-non-nil-keys
body
:email
:first_name
:last_name
)
(
mapply
upd
User
id
)))
; `upd` returns `false` if no updates occured. So in that case return a 500
(
sel
:one
User
:id
id
))
; return the updated user
;; TODO: do we want a permissions check here?
(
defendpoint
PUT
"/:id/password"
[
id
:as
{
:keys
[
body
]}]
(
let
[{
:keys
[
password
old_password
]}
body
]
(
check
(
and
password
old_password
)
[
400
"You must specify both old_password and password"
])
(
check-404
(
exists?
User
:id
id
))
(
defendpoint
PUT
"/:id/password"
[
id
:as
{{
:keys
[
password
old_password
]
:as
body
}
:body
}]
; caller must supply current and new password attributes
(
check
(
and
password
old_password
)
[
400
"You must specify both old_password and password"
])
; user must be getting their own details OR they must be a superuser to proceed
(
check-403
(
or
(
=
id
*current-user-id*
)
(
:is_superuser
@
*current-user*
)))
(
check-404
(
exists?
User
:id
id
))
;; TODO - match old password against current one
;; TODO - password encryption
(
upd
User
id
:password
password
)
(
sel
:one
User
:id
id
))
)
(
sel
:one
User
:id
id
))
(
define-routes
)
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