From 0d526cfc37ea1e52e0e9a61d1da3fe1eaa2f4559 Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Fri, 24 Aug 2018 21:35:04 +0930 Subject: [PATCH] Rename user.isActivated --- framework/core/js/src/common/models/User.js | 2 +- framework/core/js/src/forum/components/EditUserModal.js | 8 ++++---- .../core/js/src/forum/utils/alertEmailConfirmation.js | 2 +- .../core/src/Api/Serializer/CurrentUserSerializer.php | 2 +- framework/core/src/Api/Serializer/UserSerializer.php | 4 ++-- framework/core/src/User/Command/EditUserHandler.php | 2 +- framework/core/src/User/Command/RegisterUserHandler.php | 2 +- .../tests/Api/Controller/CreateUserControllerTest.php | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/framework/core/js/src/common/models/User.js b/framework/core/js/src/common/models/User.js index 284f75413..d822307ea 100644 --- a/framework/core/js/src/common/models/User.js +++ b/framework/core/js/src/common/models/User.js @@ -12,7 +12,7 @@ Object.assign(User.prototype, { username: Model.attribute('username'), displayName: Model.attribute('displayName'), email: Model.attribute('email'), - isActivated: Model.attribute('isActivated'), + isEmailConfirmed: Model.attribute('isEmailConfirmed'), password: Model.attribute('password'), avatarUrl: Model.attribute('avatarUrl'), diff --git a/framework/core/js/src/forum/components/EditUserModal.js b/framework/core/js/src/forum/components/EditUserModal.js index 4cabb05c8..81b61dcc1 100644 --- a/framework/core/js/src/forum/components/EditUserModal.js +++ b/framework/core/js/src/forum/components/EditUserModal.js @@ -15,7 +15,7 @@ export default class EditUserModal extends Modal { this.username = m.prop(user.username() || ''); this.email = m.prop(user.email() || ''); - this.isActivated = m.prop(user.isActivated() || false); + this.isEmailConfirmed = m.prop(user.isEmailConfirmed() || false); this.setPassword = m.prop(false); this.password = m.prop(user.password() || ''); this.groups = {}; @@ -50,7 +50,7 @@ export default class EditUserModal extends Modal { - {!this.isActivated() ? ( + {!this.isEmailConfirmed() ? (
{Button.component({ className: 'Button Button--block', @@ -115,11 +115,11 @@ export default class EditUserModal extends Modal { this.loading = true; const data = { username: this.username(), - isActivated: true, + isEmailConfirmed: true, }; this.props.user.save(data, {errorHandler: this.onerror.bind(this)}) .then(() => { - this.isActivated(true); + this.isEmailConfirmed(true); this.loading = false; m.redraw(); }) diff --git a/framework/core/js/src/forum/utils/alertEmailConfirmation.js b/framework/core/js/src/forum/utils/alertEmailConfirmation.js index e3e4582ba..784770cdb 100644 --- a/framework/core/js/src/forum/utils/alertEmailConfirmation.js +++ b/framework/core/js/src/forum/utils/alertEmailConfirmation.js @@ -10,7 +10,7 @@ import icon from '../../common/helpers/icon'; export default function alertEmailConfirmation(app) { const user = app.session.user; - if (!user || user.isActivated()) return; + if (!user || user.isEmailConfirmed()) return; const resendButton = Button.component({ className: 'Button Button--link', diff --git a/framework/core/src/Api/Serializer/CurrentUserSerializer.php b/framework/core/src/Api/Serializer/CurrentUserSerializer.php index 667cd3592..9e88aeff9 100644 --- a/framework/core/src/Api/Serializer/CurrentUserSerializer.php +++ b/framework/core/src/Api/Serializer/CurrentUserSerializer.php @@ -22,7 +22,7 @@ class CurrentUserSerializer extends UserSerializer $attributes = parent::getDefaultAttributes($user); $attributes += [ - 'isActivated' => (bool) $user->is_email_confirmed, + 'isEmailConfirmed' => (bool) $user->is_email_confirmed, 'email' => $user->email, 'readTime' => $this->formatDate($user->marked_all_as_read_at), 'unreadNotificationsCount' => (int) $user->getUnreadNotificationsCount(), diff --git a/framework/core/src/Api/Serializer/UserSerializer.php b/framework/core/src/Api/Serializer/UserSerializer.php index 9ac6fcb70..95792699d 100644 --- a/framework/core/src/Api/Serializer/UserSerializer.php +++ b/framework/core/src/Api/Serializer/UserSerializer.php @@ -56,8 +56,8 @@ class UserSerializer extends BasicUserSerializer if ($canEdit || $this->actor->id === $user->id) { $attributes += [ - 'isActivated' => (bool) $user->is_email_confirmed, - 'email' => $user->email + 'isEmailConfirmed' => (bool) $user->is_email_confirmed, + 'email' => $user->email ]; } diff --git a/framework/core/src/User/Command/EditUserHandler.php b/framework/core/src/User/Command/EditUserHandler.php index 09bbd69e1..65622990c 100644 --- a/framework/core/src/User/Command/EditUserHandler.php +++ b/framework/core/src/User/Command/EditUserHandler.php @@ -103,7 +103,7 @@ class EditUserHandler } } - if ($actor->isAdmin() && ! empty($attributes['isActivated'])) { + if ($actor->isAdmin() && ! empty($attributes['isEmailConfirmed'])) { $user->activate(); } diff --git a/framework/core/src/User/Command/RegisterUserHandler.php b/framework/core/src/User/Command/RegisterUserHandler.php index 417fd79e0..05029bb70 100644 --- a/framework/core/src/User/Command/RegisterUserHandler.php +++ b/framework/core/src/User/Command/RegisterUserHandler.php @@ -112,7 +112,7 @@ class RegisterUserHandler } } - if ($actor->isAdmin() && array_get($data, 'attributes.isActivated')) { + if ($actor->isAdmin() && array_get($data, 'attributes.isEmailConfirmed')) { $user->activate(); } diff --git a/framework/core/tests/Api/Controller/CreateUserControllerTest.php b/framework/core/tests/Api/Controller/CreateUserControllerTest.php index 772e51700..bbb127943 100644 --- a/framework/core/tests/Api/Controller/CreateUserControllerTest.php +++ b/framework/core/tests/Api/Controller/CreateUserControllerTest.php @@ -66,7 +66,7 @@ class CreateUserControllerTest extends ApiControllerTestCase $this->actor = $this->getAdminUser(); $response = $this->callWith(array_merge($this->data, [ - 'isActivated' => 1 + 'isEmailConfirmed' => 1 ])); $this->assertEquals(201, $response->getStatusCode());