Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dex
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
dex
Commits
c0eb36c1
Commit
c0eb36c1
authored
Jun 28, 2016
by
Eric Chiang
Committed by
GitHub
Jun 28, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #494 from ericchiang/return-409-if-resource-is-already-created
return 409 status code on duplicate email errors
parents
a95a2bfa
47ce264f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
3 deletions
+21
-3
api.go
admin/api.go
+1
-1
admin_api_test.go
integration/admin_api_test.go
+1
-1
user_api_test.go
integration/user_api_test.go
+18
-0
api.go
user/api/api.go
+1
-1
No files found.
admin/api.go
View file @
c0eb36c1
...
@@ -81,7 +81,7 @@ var (
...
@@ -81,7 +81,7 @@ var (
client
.
ErrorInvalidClientSecret
:
errorMaker
(
"bad_request"
,
"Secret must be a base64 encoded string"
,
http
.
StatusBadRequest
),
client
.
ErrorInvalidClientSecret
:
errorMaker
(
"bad_request"
,
"Secret must be a base64 encoded string"
,
http
.
StatusBadRequest
),
user
.
ErrorNotFound
:
errorMaker
(
"resource_not_found"
,
"Resource could not be found."
,
http
.
StatusNotFound
),
user
.
ErrorNotFound
:
errorMaker
(
"resource_not_found"
,
"Resource could not be found."
,
http
.
StatusNotFound
),
user
.
ErrorDuplicateEmail
:
errorMaker
(
"bad_request"
,
"Email already in use."
,
http
.
Status
BadReques
t
),
user
.
ErrorDuplicateEmail
:
errorMaker
(
"bad_request"
,
"Email already in use."
,
http
.
Status
Conflic
t
),
user
.
ErrorInvalidEmail
:
errorMaker
(
"bad_request"
,
"invalid email."
,
http
.
StatusBadRequest
),
user
.
ErrorInvalidEmail
:
errorMaker
(
"bad_request"
,
"invalid email."
,
http
.
StatusBadRequest
),
adminschema
.
ErrorInvalidRedirectURI
:
errorMaker
(
"bad_request"
,
"invalid redirectURI."
,
http
.
StatusBadRequest
),
adminschema
.
ErrorInvalidRedirectURI
:
errorMaker
(
"bad_request"
,
"invalid redirectURI."
,
http
.
StatusBadRequest
),
...
...
integration/admin_api_test.go
View file @
c0eb36c1
...
@@ -201,7 +201,7 @@ func TestCreateAdmin(t *testing.T) {
...
@@ -201,7 +201,7 @@ func TestCreateAdmin(t *testing.T) {
Email
:
"Email-1@example.com"
,
Email
:
"Email-1@example.com"
,
Password
:
"foopass"
,
Password
:
"foopass"
,
},
},
errCode
:
http
.
Status
BadReques
t
,
errCode
:
http
.
Status
Conflic
t
,
},
},
{
{
// missing Email
// missing Email
...
...
integration/user_api_test.go
View file @
c0eb36c1
...
@@ -409,6 +409,24 @@ func TestCreateUser(t *testing.T) {
...
@@ -409,6 +409,24 @@ func TestCreateUser(t *testing.T) {
},
},
},
},
},
},
{
// Duplicate email
req
:
schema
.
UserCreateRequest
{
User
:
&
schema
.
User
{
Email
:
"Email-1@example.com"
,
DisplayName
:
"New User"
,
EmailVerified
:
true
,
Admin
:
false
,
CreatedAt
:
clock
.
Now
()
.
Format
(
time
.
RFC3339
),
},
RedirectURL
:
testRedirectURL
.
String
(),
},
token
:
userGoodToken
,
wantCode
:
http
.
StatusConflict
,
},
{
{
req
:
schema
.
UserCreateRequest
{
req
:
schema
.
UserCreateRequest
{
...
...
user/api/api.go
View file @
c0eb36c1
...
@@ -31,7 +31,7 @@ var (
...
@@ -31,7 +31,7 @@ var (
ErrorInvalidClient
=
newError
(
"invalid_client"
,
"invalid email."
,
http
.
StatusBadRequest
)
ErrorInvalidClient
=
newError
(
"invalid_client"
,
"invalid email."
,
http
.
StatusBadRequest
)
ErrorDuplicateEmail
=
newError
(
"duplicate_email"
,
"Email already in use."
,
http
.
Status
BadReques
t
)
ErrorDuplicateEmail
=
newError
(
"duplicate_email"
,
"Email already in use."
,
http
.
Status
Conflic
t
)
ErrorResourceNotFound
=
newError
(
"resource_not_found"
,
"Resource could not be found."
,
http
.
StatusNotFound
)
ErrorResourceNotFound
=
newError
(
"resource_not_found"
,
"Resource could not be found."
,
http
.
StatusNotFound
)
ErrorUnauthorized
=
newError
(
"unauthorized"
,
"Necessary credentials not provided."
,
http
.
StatusUnauthorized
)
ErrorUnauthorized
=
newError
(
"unauthorized"
,
"Necessary credentials not provided."
,
http
.
StatusUnauthorized
)
...
...
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