NyaaPantsu / nyaa

Nyaa.se replacement written in golang
MIT License
994 stars 148 forks source link

User not created when registering a new user. #1764

Closed HamzaAnis closed 6 years ago

HamzaAnis commented 6 years ago

Registering a new user not working as a UNIQUE constraint failed on user.email. When registering a new user empty string ('') is taken as input in the user.email and registration is successful for the first user in the database. When a second user registers in the database the email unique constraint failed and the user is not created.

When the first user is created in email textbox I wrote testing@gmail.com but in database it was not taken from the textbox.

?[35m(C:/Users/hamza/go/src/github.com/NyaaPantsu/nyaa/models/users/create.go:44)?[0m
?[33m[2018-05-18 22:26:11]?[0m  ?[36;1m[2.99ms]?[0m  INSERT INTO "users" ("username","password","email","status","created_at","updated_at","api_token","api_token_expiry","language","theme","alt_colors","old_nav","mascot","mascot_url","anidex_api_token","nyaasi_api_token","tokyotosho_api_token","settings","pantsu","md5") VALUES ('testing','$2a$10$YCY.3mOIJ6VOKkLqEL04SuAlUOv24uIUHgdntUjvwuUqOdzkJzn1.','','0','2018-05-18 22:26:11','2018-05-18 22:26:11','192896a7952e99b37d6947b94bab7a0184254669d58a9947f0354bfcea0bd110','1970-01-01 05:00:00','','','','','','','','','','{"settings":{"followed":false,"followed_email":false,"new_comment":true,"new_comment_email":false,"new_follower":false,"new_follower_email":false,"new_responses":false,"new_responses_email":false,"new_torrent":true,"new_torrent_email":false}}','1','9ad574806427070b94735f216e9abdc1')
?[36;31m[1 rows affected or returned ]?[0m

For the second user the email was testing2@gmail.com but it is not passed to the database and UNIQUE constraint fails for email.

?[35m(C:/Users/hamza/go/src/github.com/NyaaPantsu/nyaa/models/users/create.go:44)?[0m
?[33m[2018-05-18 22:27:08]?[0m ?[31;1m UNIQUE constraint failed: users.email ?[0m
?[35m(C:/Users/hamza/go/src/github.com/NyaaPantsu/nyaa/models/users/create.go:44)?[0m
?[33m[2018-05-18 22:27:08]?[0m  ?[36;1m[0.99ms]?[0m  INSERT INTO "users" ("username","password","email","status","created_at","updated_at","api_token","api_token_expiry","language","theme","alt_colors","old_nav","mascot","mascot_url","anidex_api_token","nyaasi_api_token","tokyotosho_api_token","settings","pantsu","md5") VALUES ('testing2','$2a$10$OkIg/D.PHYwLwiyRH5FyduKCfFvtdeCor53JZpK.OqMdOt5VyO4HC','','0','2018-05-18 22:27:08','2018-05-18 22:27:08','6b701c7365201baaffcfe8b4b0bb9fbec25f08d7efe0ee5b33fd8e54b454288a','1970-01-01 05:00:00','','','','','','','','','','{"settings":{"followed":false,"followed_email":false,"new_comment":true,"new_comment_email":false,"new_follower":false,"new_follower_email":false,"new_responses":false,"new_responses_email":false,"new_torrent":true,"new_torrent_email":false}}','1','8d9b92209279ff11556f498a5db2300a')
?[36;31m[0 rows affected or returned ]?[0m
[GIN] 2018/05/18 - 22:27:08 |?[97;42m 200 ?[0m|    211.1098ms | ::1 |?[97;46m  ?[0m POST    /register
[GIN] 2018/05/18 - 22:27:08 |?[97;42m 200 ?[0m|      7.9856ms | ::1 |?[97;44m  ?[0m GET     /captcha/RMKxYYgZSZ6gXcrzOjwC.png
[GIN] 2018/05/18 - 22:27:09 |?[97;42m 206 ?[0m|     41.4226ms | ::1 |?[97;44m  ?[0m GET     /captcha/RMKxYYgZSZ6gXcrzOjwC.wav

Only one user can be inserted and for all the other users it can not be created.

If someone is maintaining this then can you fix this issue in the next commit. Otherwise I'll take a look and try to fix it.

HamzaAnis commented 6 years ago

The email from the form was not set. It will be fixed when you will pass the value from the form to the database.