diff --git a/app/Http/Controllers/Api/UserApiController.php b/app/Http/Controllers/Api/UserApiController.php index 2e02bd40..ab1ff9a4 100644 --- a/app/Http/Controllers/Api/UserApiController.php +++ b/app/Http/Controllers/Api/UserApiController.php @@ -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; + } } \ No newline at end of file diff --git a/app/ModelSerializers/Auth/UserSerializer.php b/app/ModelSerializers/Auth/UserSerializer.php index 02db3bb2..063ddc81 100644 --- a/app/ModelSerializers/Auth/UserSerializer.php +++ b/app/ModelSerializers/Auth/UserSerializer.php @@ -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' ]; } \ No newline at end of file diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index de71134b..34d6de93 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -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; diff --git a/app/Services/Auth/UserService.php b/app/Services/Auth/UserService.php index 1a367944..55366939 100644 --- a/app/Services/Auth/UserService.php +++ b/app/Services/Auth/UserService.php @@ -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() ) diff --git a/app/libs/Auth/Models/User.php b/app/libs/Auth/Models/User.php index f2b2fdc3..76ad41d8 100644 --- a/app/libs/Auth/Models/User.php +++ b/app/libs/Auth/Models/User.php @@ -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; } diff --git a/public/assets/js/admin/edit-user.js b/public/assets/js/admin/edit-user.js index d07afc30..2893d97f 100644 --- a/public/assets/js/admin/edit-user.js +++ b/public/assets/js/admin/edit-user.js @@ -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');