Fix on User CRUD

fixed UX on user update on admin

Change-Id: Ic20bc5054b94cae58d4b90a9bb19d1a7e7505f56
Signed-off-by: smarcet <smarcet@gmail.com>
This commit is contained in:
smarcet 2020-03-31 11:10:08 -03:00
parent 87c4eba4fa
commit d1b6174e4a
6 changed files with 20 additions and 8 deletions

View File

@ -202,6 +202,8 @@ final class UserApiController extends APICRUDController {
'language' => 'nullable|string',
'birthday' => 'nullable|date_format:U',
'password' => 'sometimes|string|min:8|confirmed',
'email_verified' => 'nullable|boolean',
'active' => 'nullable|boolean'
];
}
@ -246,6 +248,8 @@ final class UserApiController extends APICRUDController {
'language' => 'nullable|string',
'birthday' => 'nullable|date_format:U',
'password' => 'sometimes|string|min:8|confirmed',
'email_verified' => 'nullable|boolean',
'active' => 'nullable|boolean'
];
}
@ -259,4 +263,7 @@ final class UserApiController extends APICRUDController {
return $this->update($myId);
}
protected function serializerType():string{
return SerializerRegistry::SerializerType_Private;
}
}

View File

@ -29,11 +29,13 @@ final class PublicUserSerializer extends BaseUserSerializer {
}
final class PrivateUserSerializer extends BaseUserSerializer {
protected static $array_mappings = [
'Email' => 'email:json_string',
'SpamType' => 'spam_type:json_string',
'Identifier' => 'identifier:json_string',
'LastLoginDate' => 'last_login_date:datetime_epoch',
'Active' => 'active:json_boolean',
'EmailVerified' => 'email_verified:json_boolean'
];
}

View File

@ -12,8 +12,6 @@
* limitations under the License.
**/
use App\Events\OAuth2ClientLocked;
use App\Events\UserActivated;
use App\Events\UserDeactivated;
use App\Events\UserEmailUpdated;
use App\Events\UserLocked;
use App\Events\UserPasswordResetRequestCreated;

View File

@ -181,7 +181,7 @@ final class UserService extends AbstractService implements IUserService
(
sprintf
(
"user %s (%s) has already verified his/her email",
"User %s (%s) has already verified his/her email.",
$user->getEmail(),
$user->getId()
)

View File

@ -1435,14 +1435,19 @@ SQL;
public function verifyEmail()
{
if (!$this->email_verified) {
$this->email_verified = true;
$this->active = true;
$this->lock = false;
$this->email_verified = true;
$this->spam_type = self::SpamTypeHam;
$this->active = true;
$this->lock = false;
$this->email_verified_date = new \DateTime('now', new \DateTimeZone('UTC'));
Event::fire(new UserEmailVerified(
$this->getId()
)
);
Event::fire(new UserSpamStateUpdated(
$this->getId()
)
);
}
return $this;
}

View File

@ -160,14 +160,14 @@ $(document).ready(function() {
contentType: "application/json; charset=utf-8",
dataType: "json",
timeout:60000,
success: function (data,textStatus,jqXHR) {
success: function (data, textStatus, jqXHR) {
$('body').ajax_loader('stop');
swal({
title: "Success!",
type: "success",
text: "User info updated successfully!",
});
$('#spam-type').val(data.spam_type);
},
error: function (jqXHR, textStatus, errorThrown) {
$('body').ajax_loader('stop');