cornflourblue / aspnet-core-3-signup-verification-api

ASP.NET Core 3.1 - Boilerplate API with Email Sign Up, Verification, Authentication & Forgot Password
https://jasonwatmore.com/post/2020/07/06/aspnet-core-3-boilerplate-api-with-email-sign-up-verification-authentication-forgot-password
MIT License
226 stars 93 forks source link

PUT Accounts/id Cannot Handle Password Property with Empty String. #1

Closed twinmind closed 3 years ago

twinmind commented 4 years ago

When running together with react app, editing existing user creates a payload like this

{"title":"Mr","firstName":"John","lastName":"Smith","email":"john@smith.com","role":"User","password":"","confirmPassword":""}

And this results in error like on the screenshot. bad_request If payload is replaced with nulls, i.e.

{"title":"Mr","firstName":"John","lastName":"Smith","email":"john@smith.com","role":"User","password":null,"confirmPassword":null}

Then it works fine.

My guess is that the attribute [MinLength(6)] on Password property in UpdateRequest model doesn't allow empty string, but is happy with null.

cornflourblue commented 3 years ago

Thanks Alexey, I've just updated the UpdateRequest.cs model to allow empty strings for all parameters - https://github.com/cornflourblue/aspnet-core-3-signup-verification-api/blob/master/Models/Accounts/UpdateRequest.cs