fair-research / minid-server

5 stars 3 forks source link

PUT user object not validating - it's creating a new user. #5

Open bheavner opened 6 years ago

bheavner commented 6 years ago

From this, I expect a PUT on a user object should validate a user (and a POST should register a new user - https://github.com/fair-research/minid-server/blob/master/rest-api.rst . However, when I do a PUT with an existing user, I get a 201 CREATED response and an email is sent with a new registration code:

-> PUT /minid/user HTTP/1.1
-> Host: minid.bd2k.org
-> User-Agent: libcurl/7.54.0 r-curl/3.2 httr/1.3.1
-> Accept-Encoding: gzip, deflate
-> Accept: application/json, text/xml, application/xml, */*
-> Content-Type: application/json
-> Content-Length: 127
-> 
>> {"email":"bheavner@gmail.com","name":"Ben Heavner","orcid":"0000-0003-2898-9044","code":"<my secret code>"}

<- HTTP/1.1 201 CREATED
<- Date: Thu, 26 Apr 2018 23:52:54 GMT
<- Server: Apache/2.4.7 (Ubuntu)
<- Content-Length: 96
<- Content-Type: application/json

Further, the content returned does not have a code - only the email does:

Response [http://minid.bd2k.org/minid/user]
  Date: 2018-04-27 16:25
  Status: 201
  Content-Type: application/json
  Size: 96 B
{
  "email": "bheavner@gmail.com", 
  "name": "Ben Heavner", 
  "orcid": "0000-0003-2898-9044"
}
bheavner commented 6 years ago

A POST has the same behavior, and will create a new code for an existing user:

> httr::POST("http://minid.bd2k.org/minid/user",
+           body = list(email = email(config),
+                        name = user(config),
+                        orcid = orcid(config)),
+           encode = "json",
+           httr::verbose())
-> POST /minid/user HTTP/1.1
-> Host: minid.bd2k.org
-> User-Agent: libcurl/7.54.0 r-curl/3.2 httr/1.3.1
-> Accept-Encoding: gzip, deflate
-> Accept: application/json, text/xml, application/xml, */*
-> Content-Type: application/json
-> Content-Length: 81
-> 
>> {"email":"bheavner@gmail.com","name":"Ben Heavner","orcid":"0000-0003-2898-9044"}

<- HTTP/1.1 201 CREATED
<- Date: Fri, 27 Apr 2018 16:33:22 GMT
<- Server: Apache/2.4.7 (Ubuntu)
<- Content-Length: 96
<- Content-Type: application/json
<- 
Response [http://minid.bd2k.org/minid/user]
  Date: 2018-04-27 16:33
  Status: 201
  Content-Type: application/json
  Size: 96 B
{
  "email": "bheavner@gmail.com", 
  "name": "Ben Heavner", 
  "orcid": "0000-0003-2898-9044"