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