From 763c5abce79d1c13cf4c6d0df9ff78e907631d85 Mon Sep 17 00:00:00 2001 From: Rafael Rodrigues Date: Thu, 2 Sep 2021 09:08:15 -0300 Subject: [PATCH] Update ValidationRules.php When a request of type "application/json" was received, it caused an Exception of type ErrorException with the message "Undefined offset: 1". This was because the buildUserFromRequest method in the myth-auth/src/Authentication/Passwords/ValidationRules.php file was not prepared for this request. This patch fixes this issue. --- src/Authentication/Passwords/ValidationRules.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Authentication/Passwords/ValidationRules.php b/src/Authentication/Passwords/ValidationRules.php index f39ca2a7..9903b8ca 100644 --- a/src/Authentication/Passwords/ValidationRules.php +++ b/src/Authentication/Passwords/ValidationRules.php @@ -69,7 +69,14 @@ protected function buildUserFromRequest() $fields = $this->prepareValidFields(); $data = array_filter(service('request')->getPost($fields)); - + + if (empty($data)) { + $data = array_intersect_key( + json_decode(service('request')->getBody(), true), + array_fill_keys($fields, null) + ); + } + return new User($data); }