You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey. I realized something today. Consider this example:
I put {{ .csrfField }} in the template and CSRF middleware verifies it
Processing the request:
type LoginUser struct {
Username string json:"username" form:"username" validate:"required,min=3"
Password string json:"password" form:"password" validate:"required,min=4"
}
...
Because my LoginUser{} struct doesn't have any field with form:"csrf.token"
Please add a feature to ReadForm that would ignore csrf.token field and not try to fill the struct with that value
I know that there's a way to fix it (add if !iris.IsErrPath(err) to the error checking or read the values one by one) but please add a fix to it
Thanks
The text was updated successfully, but these errors were encountered:
mostafa-binesh
changed the title
[BUG] ctx.ReadForm fires error if there is no csrf value in struct
[Feature Request] ctx.ReadForm fires error if there is no csrf value in struct
Jul 30, 2022
Hey. I realized something today. Consider this example:
I put {{ .csrfField }} in the template and CSRF middleware verifies it
Processing the request:
type LoginUser struct {
Username string
json:"username" form:"username" validate:"required,min=3"
Password string
json:"password" form:"password" validate:"required,min=4"
}
...
func Proccesing(ctx iris.Context) {
user := LoginUser{}
err := ctx.ReadForm(&user)
if err != nil {
ctx.Writef("Error: %v",err)
return
}
...
}
It actually prints
Because my LoginUser{} struct doesn't have any field with
form:"csrf.token"
Please add a feature to ReadForm that would ignore csrf.token field and not try to fill the struct with that value
I know that there's a way to fix it (add if !iris.IsErrPath(err) to the error checking or read the values one by one) but please add a fix to it
Thanks
The text was updated successfully, but these errors were encountered: