Add admin operation to change user's verification status
This commit is contained in:
parent
6c66898fc9
commit
3c8f0c9e22
|
|
@ -251,10 +251,10 @@ class AdminController extends Controller
|
|||
$users = collect();
|
||||
|
||||
if ($request->has('uid')) {
|
||||
$users = User::select(['uid', 'email', 'nickname', 'score', 'permission', 'register_at'])
|
||||
$users = User::select(['uid', 'email', 'nickname', 'score', 'permission', 'verified', 'register_at'])
|
||||
->where('uid', intval($request->input('uid')));
|
||||
} else {
|
||||
$users = User::select(['uid', 'email', 'nickname', 'score', 'permission', 'register_at']);
|
||||
$users = User::select(['uid', 'email', 'nickname', 'score', 'permission', 'verified', 'register_at']);
|
||||
}
|
||||
|
||||
return Datatables::of($users)->editColumn('email', function ($user) {
|
||||
|
|
@ -326,6 +326,13 @@ class AdminController extends Controller
|
|||
|
||||
return json(trans('admin.users.operations.email.success'), 0);
|
||||
|
||||
} elseif ($action == "verification") {
|
||||
|
||||
$user->verified = !$user->verified;
|
||||
$user->save();
|
||||
|
||||
return json(trans('admin.users.operations.verification.success'), 0);
|
||||
|
||||
} elseif ($action == "nickname") {
|
||||
$this->validate($request, [
|
||||
'nickname' => 'required|no_special_chars'
|
||||
|
|
|
|||
|
|
@ -58,10 +58,16 @@ const usersTableColumnDefs = [
|
|||
},
|
||||
{
|
||||
targets: 6,
|
||||
data: 'register_at'
|
||||
data: 'verified',
|
||||
className: 'verification',
|
||||
render: data => trans('admin.' + (data ? 'verified' : 'unverified'))
|
||||
},
|
||||
{
|
||||
targets: 7,
|
||||
data: 'register_at'
|
||||
},
|
||||
{
|
||||
targets: 8,
|
||||
data: 'operations',
|
||||
searchable: false,
|
||||
orderable: false,
|
||||
|
|
@ -108,6 +114,7 @@ function renderUsersTableOperations(currentUserPermission, type, row) {
|
|||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a onclick="changeUserEmail(${row.uid});">${trans('admin.changeEmail')}</a></li>
|
||||
<li><a onclick="changeUserVerification(${row.uid});">${trans('admin.changeVerification')}</a></li>
|
||||
<li><a onclick="changeUserNickName(${row.uid});">${trans('admin.changeNickName')}</a></li>
|
||||
<li><a onclick="changeUserPwd(${row.uid});">${trans('admin.changePassword')}</a></li>
|
||||
${adminOption}
|
||||
|
|
@ -155,6 +162,31 @@ async function changeUserEmail(uid) {
|
|||
}
|
||||
}
|
||||
|
||||
async function changeUserVerification(uid) {
|
||||
try {
|
||||
const { errno, msg } = await fetch({
|
||||
type: 'POST',
|
||||
url: url('admin/users?action=verification'),
|
||||
dataType: 'json',
|
||||
data: { uid: uid }
|
||||
});
|
||||
|
||||
if (errno === 0) {
|
||||
const original = $(`#user-${uid} > td.verification`).text();
|
||||
|
||||
$(`#user-${uid} > td.verification`).text(
|
||||
original === trans('admin.unverified') ? trans('admin.verified') : trans('admin.unverified')
|
||||
);
|
||||
|
||||
toastr.success(msg);
|
||||
} else {
|
||||
toastr.warning(msg);
|
||||
}
|
||||
} catch (error) {
|
||||
showAjaxError(error);
|
||||
}
|
||||
}
|
||||
|
||||
async function changeUserNickName(uid) {
|
||||
const dom = $(`tr#user-${uid} > td:nth-child(3)`);
|
||||
let newNickName = '';
|
||||
|
|
@ -342,5 +374,6 @@ if (process.env.NODE_ENV === 'test') {
|
|||
changeAdminStatus,
|
||||
deleteUserAccount,
|
||||
changeUserNickName,
|
||||
changeUserVerification,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ users:
|
|||
banned: Banned
|
||||
admin: Admin
|
||||
super-admin: Super Admin
|
||||
verification:
|
||||
title: Account Verification
|
||||
operations:
|
||||
title: Operations
|
||||
non-existent: No such user.
|
||||
|
|
@ -25,6 +27,8 @@ users:
|
|||
change: Edit Email
|
||||
existed: :email is existed.
|
||||
success: Email changed successfully.
|
||||
verification:
|
||||
success: Account verification status switched successfully.
|
||||
nickname:
|
||||
change: Edit Nickname
|
||||
success: Nickname changed successfully.
|
||||
|
|
|
|||
|
|
@ -138,6 +138,7 @@
|
|||
changeEmail: 'Edit Email',
|
||||
changeNickName: 'Edit Nickname',
|
||||
changePassword: 'Edit Password',
|
||||
changeVerification: 'Switch Verification Status',
|
||||
newUserEmail: 'Please enter the new email:',
|
||||
newUserNickname: 'Please enter the new nickname:',
|
||||
newUserPassword: 'Please enter the new password:',
|
||||
|
|
@ -152,6 +153,10 @@
|
|||
admin: 'Admin',
|
||||
superAdmin: 'Super Admin',
|
||||
|
||||
// Verification
|
||||
unverified: 'Unverified',
|
||||
verified: 'Verified',
|
||||
|
||||
// Players
|
||||
textureType: 'Texture Type',
|
||||
skin: 'Skin (:model Model)',
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ users:
|
|||
banned: 封禁
|
||||
admin: 管理员
|
||||
super-admin: 超级管理员
|
||||
verification:
|
||||
title: 邮箱验证
|
||||
operations:
|
||||
title: 更多操作
|
||||
non-existent: 用户不存在
|
||||
|
|
@ -25,6 +27,8 @@ users:
|
|||
change: 修改邮箱
|
||||
existed: :email 已被占用
|
||||
success: 邮箱修改成功
|
||||
verification:
|
||||
success: 用户的邮箱验证状态已修改
|
||||
nickname:
|
||||
change: 修改昵称
|
||||
success: 昵称已成功设置为 :new
|
||||
|
|
|
|||
|
|
@ -140,6 +140,7 @@
|
|||
changeEmail: '修改邮箱',
|
||||
changeNickName: '修改昵称',
|
||||
changePassword: '更改密码',
|
||||
changeVerification: '修改邮箱验证状态',
|
||||
newUserEmail: '请输入新邮箱:',
|
||||
newUserNickname: '请输入新昵称:',
|
||||
newUserPassword: '请输入新密码:',
|
||||
|
|
@ -154,6 +155,10 @@
|
|||
admin: '管理员',
|
||||
superAdmin: '超级管理员',
|
||||
|
||||
// Verification
|
||||
unverified: '未验证',
|
||||
verified: '已验证',
|
||||
|
||||
// Players
|
||||
textureType: '材质类型',
|
||||
skin: '皮肤(:model 模型)',
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
<th>{{ trans('general.user.score') }}</th>
|
||||
<th>{{ trans('admin.users.players-count.title') }}</th>
|
||||
<th>{{ trans('admin.users.status.title') }}</th>
|
||||
<th>{{ trans('admin.users.verification.title') }}</th>
|
||||
<th>{{ trans('general.user.register-at') }}</th>
|
||||
<th>{{ trans('general.operations') }}</th>
|
||||
</tr>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user