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
ebe302ab
Commit
ebe302ab
authored
6 years ago
by
Ryan Senior
Browse files
Options
Downloads
Patches
Plain Diff
Switched user api errors to a map containing the error
parent
40ef0245
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
-5
5 additions, 5 deletions
src/metabase/api/user.clj
test/metabase/api/user_test.clj
+3
-3
3 additions, 3 deletions
test/metabase/api/user_test.clj
with
8 additions
and
8 deletions
src/metabase/api/user.clj
+
5
−
5
View file @
ebe302ab
...
...
@@ -52,8 +52,8 @@
last_name
su/NonBlankString
email
su/Email
}
(
api/check-superuser
)
(
api/check
(
not
(
db/exists?
User
:email
email
))
[
400
"Email address already in use."
]
)
(
api/check
p
(
not
(
db/exists?
User
:email
email
))
"email"
"Email address already in use."
)
(
user/invite-user!
first_name
last_name
email
password
@
api/*current-user*
))
(
api/defendpoint
GET
"/current"
...
...
@@ -79,8 +79,8 @@
;; only allow updates if the specified account is active
(
api/check-404
(
db/exists?
User,
:id
id,
:is_active
true
))
;; can't change email if it's already taken BY ANOTHER ACCOUNT
(
api/check
(
not
(
db/exists?
User,
:email
email,
:id
[
:not=
id
]))
[
400
"Email address already associated to another user."
]
)
(
api/check
p
(
not
(
db/exists?
User,
:email
email,
:id
[
:not=
id
]))
"email"
"Email address already associated to another user."
)
(
api/check-500
(
db/update-non-nil-keys!
User
id
:email
email
:first_name
first_name
...
...
@@ -97,7 +97,7 @@
(
api/check-404
user
)
;; Can only reactivate inactive users
(
api/check
(
not
(
:is_active
user
))
[
400
"Not able to reactivate an active user"
])
[
400
{
:message
"Not able to reactivate an active user"
}
])
(
reactivate-user!
user
)))
...
...
This diff is collapsed.
Click to expand it.
test/metabase/api/user_test.clj
+
3
−
3
View file @
ebe302ab
...
...
@@ -111,12 +111,12 @@
;; Attempting to reactivate an already active user should fail
(
expect
"Not able to reactivate an active user"
{
:message
"Not able to reactivate an active user"
}
((
user->client
:crowberto
)
:put
400
(
format
"user/%s/reactivate"
(
u/get-id
(
fetch-user
:rasta
)))))
;; Attempting to create a new user with the same email as an existing user should fail
(
expect
"Email address already in use."
{
:errors
{
:email
"Email address already in use."
}}
((
user->client
:crowberto
)
:post
400
"user"
{
:first_name
"Something"
:last_name
"Random"
:email
(
:email
(
fetch-user
:rasta
))}))
...
...
@@ -201,7 +201,7 @@
;; ## PUT /api/user/:id
;; Test that updating a user's email to an existing inactive user's email fails
(
expect
"Email address already associated to another user."
{
:errors
{
:email
"Email address already associated to another user."
}}
(
let
[
trashbird
(
fetch-user
:trashbird
)
rasta
(
fetch-user
:rasta
)]
((
user->client
:crowberto
)
:put
400
(
str
"user/"
(
u/get-id
rasta
))
(
select-keys
trashbird
[
:email
]))))
...
...
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