mirror of
https://github.com/flarum/framework.git
synced 2024-12-04 08:13:39 +08:00
Rename user.isActivated
This commit is contained in:
parent
666dfe2eb8
commit
0d526cfc37
|
@ -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'),
|
||||||
|
|
|
@ -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();
|
||||||
})
|
})
|
||||||
|
|
|
@ -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',
|
||||||
|
|
|
@ -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(),
|
||||||
|
|
|
@ -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
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ class EditUserHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($actor->isAdmin() && ! empty($attributes['isActivated'])) {
|
if ($actor->isAdmin() && ! empty($attributes['isEmailConfirmed'])) {
|
||||||
$user->activate();
|
$user->activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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());
|
||||||
|
|
Loading…
Reference in New Issue
Block a user