Rename user.isActivated

This commit is contained in:
Toby Zerner 2018-08-24 21:35:04 +09:30
parent 666dfe2eb8
commit 0d526cfc37
8 changed files with 12 additions and 12 deletions

View File

@ -12,7 +12,7 @@ Object.assign(User.prototype, {
username: Model.attribute('username'), username: Model.attribute('username'),
displayName: Model.attribute('displayName'), displayName: Model.attribute('displayName'),
email: Model.attribute('email'), email: Model.attribute('email'),
isActivated: Model.attribute('isActivated'), isEmailConfirmed: Model.attribute('isEmailConfirmed'),
password: Model.attribute('password'), password: Model.attribute('password'),
avatarUrl: Model.attribute('avatarUrl'), avatarUrl: Model.attribute('avatarUrl'),

View File

@ -15,7 +15,7 @@ export default class EditUserModal extends Modal {
this.username = m.prop(user.username() || ''); this.username = m.prop(user.username() || '');
this.email = m.prop(user.email() || ''); 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.setPassword = m.prop(false);
this.password = m.prop(user.password() || ''); this.password = m.prop(user.password() || '');
this.groups = {}; this.groups = {};
@ -50,7 +50,7 @@ export default class EditUserModal extends Modal {
<input className="FormControl" placeholder={extractText(app.translator.trans('core.forum.edit_user.email_label'))} <input className="FormControl" placeholder={extractText(app.translator.trans('core.forum.edit_user.email_label'))}
bidi={this.email} /> bidi={this.email} />
</div> </div>
{!this.isActivated() ? ( {!this.isEmailConfirmed() ? (
<div> <div>
{Button.component({ {Button.component({
className: 'Button Button--block', className: 'Button Button--block',
@ -115,11 +115,11 @@ export default class EditUserModal extends Modal {
this.loading = true; this.loading = true;
const data = { const data = {
username: this.username(), username: this.username(),
isActivated: true, isEmailConfirmed: true,
}; };
this.props.user.save(data, {errorHandler: this.onerror.bind(this)}) this.props.user.save(data, {errorHandler: this.onerror.bind(this)})
.then(() => { .then(() => {
this.isActivated(true); this.isEmailConfirmed(true);
this.loading = false; this.loading = false;
m.redraw(); m.redraw();
}) })

View File

@ -10,7 +10,7 @@ import icon from '../../common/helpers/icon';
export default function alertEmailConfirmation(app) { export default function alertEmailConfirmation(app) {
const user = app.session.user; const user = app.session.user;
if (!user || user.isActivated()) return; if (!user || user.isEmailConfirmed()) return;
const resendButton = Button.component({ const resendButton = Button.component({
className: 'Button Button--link', className: 'Button Button--link',

View File

@ -22,7 +22,7 @@ class CurrentUserSerializer extends UserSerializer
$attributes = parent::getDefaultAttributes($user); $attributes = parent::getDefaultAttributes($user);
$attributes += [ $attributes += [
'isActivated' => (bool) $user->is_email_confirmed, 'isEmailConfirmed' => (bool) $user->is_email_confirmed,
'email' => $user->email, 'email' => $user->email,
'readTime' => $this->formatDate($user->marked_all_as_read_at), 'readTime' => $this->formatDate($user->marked_all_as_read_at),
'unreadNotificationsCount' => (int) $user->getUnreadNotificationsCount(), 'unreadNotificationsCount' => (int) $user->getUnreadNotificationsCount(),

View File

@ -56,8 +56,8 @@ class UserSerializer extends BasicUserSerializer
if ($canEdit || $this->actor->id === $user->id) { if ($canEdit || $this->actor->id === $user->id) {
$attributes += [ $attributes += [
'isActivated' => (bool) $user->is_email_confirmed, 'isEmailConfirmed' => (bool) $user->is_email_confirmed,
'email' => $user->email 'email' => $user->email
]; ];
} }

View File

@ -103,7 +103,7 @@ class EditUserHandler
} }
} }
if ($actor->isAdmin() && ! empty($attributes['isActivated'])) { if ($actor->isAdmin() && ! empty($attributes['isEmailConfirmed'])) {
$user->activate(); $user->activate();
} }

View File

@ -112,7 +112,7 @@ class RegisterUserHandler
} }
} }
if ($actor->isAdmin() && array_get($data, 'attributes.isActivated')) { if ($actor->isAdmin() && array_get($data, 'attributes.isEmailConfirmed')) {
$user->activate(); $user->activate();
} }

View File

@ -66,7 +66,7 @@ class CreateUserControllerTest extends ApiControllerTestCase
$this->actor = $this->getAdminUser(); $this->actor = $this->getAdminUser();
$response = $this->callWith(array_merge($this->data, [ $response = $this->callWith(array_merge($this->data, [
'isActivated' => 1 'isEmailConfirmed' => 1
])); ]));
$this->assertEquals(201, $response->getStatusCode()); $this->assertEquals(201, $response->getStatusCode());