ngiachou / WalletHero

A hero we all deserve. Tracking your monthly costs was never been so much fun.
GNU General Public License v3.0
0 stars 0 forks source link

Implementing registration functionality #39

Closed pagidas closed 5 years ago

pagidas commented 5 years ago

Solves #32

pagidas commented 5 years ago

Demonstrates that logic in POST /register works

Screenshot 2019-05-16 at 13 13 51

One big issue

Django's Redirect mechanism for views (which always adds a trailing slash at the end for correct resource request) does not hold the state of the request. So when we send data in JSON format in POST, the body is not send back. Thus, the call must be made explicitly at POST /register/ (adding a slash at the end manually)

Response

Screenshot 2019-05-16 at 13 15 20

Test

Then if we hit GET /users

Screenshot 2019-05-16 at 13 47 04
ngiachou commented 5 years ago

I have one question. Why the body of the POST request has that structure? Couldn't it be as following?

{
  "name": "Nikos",
  "surname": "Giachoudis",
  "username": "lpax",
  "password": "1234"
}
pagidas commented 5 years ago

@elpaxoudis The body of the POST request can be exactly as you said, too. But it is a good practice, when I am reading the code, to know that I parse the request body with a key named 'user'. I did it to experiment with a the parser, too. If you have trouble making that kind of request, I could change it.