forked from AkkomaGang/admin-fe
Disable moderation of users that don't have nicknames or IDs
This commit is contained in:
parent
dd4b5b2f21
commit
7b7a05170a
5 changed files with 37 additions and 20 deletions
|
@ -238,7 +238,8 @@ export default {
|
||||||
unconfirmedEmail: 'User didn\'t confirm the email',
|
unconfirmedEmail: 'User didn\'t confirm the email',
|
||||||
confirmAccount: 'Confirm account',
|
confirmAccount: 'Confirm account',
|
||||||
confirmAccounts: 'Confirm accounts',
|
confirmAccounts: 'Confirm accounts',
|
||||||
resendConfirmation: 'Resend confirmation email'
|
resendConfirmation: 'Resend confirmation email',
|
||||||
|
invalidUser: 'This user is invalid and can\'t be modified'
|
||||||
},
|
},
|
||||||
statuses: {
|
statuses: {
|
||||||
statuses: 'Statuses',
|
statuses: 'Statuses',
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
<el-dropdown-item v-if="report.state !== 'closed'" @click.native="changeReportState('closed', report.id)">{{ $t('reports.close') }}</el-dropdown-item>
|
<el-dropdown-item v-if="report.state !== 'closed'" @click.native="changeReportState('closed', report.id)">{{ $t('reports.close') }}</el-dropdown-item>
|
||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
</el-dropdown>
|
</el-dropdown>
|
||||||
<moderate-user-dropdown :account="report.account"/>
|
<moderate-user-dropdown v-if="validAccount(report.account)" :account="report.account"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
@ -179,6 +179,9 @@ export default {
|
||||||
},
|
},
|
||||||
showStatuses(statuses = []) {
|
showStatuses(statuses = []) {
|
||||||
return statuses.length > 0
|
return statuses.length > 0
|
||||||
|
},
|
||||||
|
validAccount(account) {
|
||||||
|
return account.nickname && account.id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,33 +165,33 @@ export default {
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
grantRight: (right) => () => {
|
grantRight: (right) => () => {
|
||||||
const filterUsersFn = user => user.local && !user.roles[right] && this.$store.state.user.id !== user.id
|
const filterUsersFn = user => user.nickname && user.id && user.local && !user.roles[right] && this.$store.state.user.id !== user.id
|
||||||
const addRightFn = async(users) => await this.$store.dispatch('AddRight', { users, right })
|
const addRightFn = async(users) => await this.$store.dispatch('AddRight', { users, right })
|
||||||
const filtered = this.selectedUsers.filter(filterUsersFn)
|
const filtered = this.selectedUsers.filter(filterUsersFn)
|
||||||
|
|
||||||
applyAction(filtered, addRightFn)
|
applyAction(filtered, addRightFn)
|
||||||
},
|
},
|
||||||
revokeRight: (right) => () => {
|
revokeRight: (right) => () => {
|
||||||
const filterUsersFn = user => user.local && user.roles[right] && this.$store.state.user.id !== user.id
|
const filterUsersFn = user => user.nickname && user.id && user.local && user.roles[right] && this.$store.state.user.id !== user.id
|
||||||
const deleteRightFn = async(users) => await this.$store.dispatch('DeleteRight', { users, right })
|
const deleteRightFn = async(users) => await this.$store.dispatch('DeleteRight', { users, right })
|
||||||
const filtered = this.selectedUsers.filter(filterUsersFn)
|
const filtered = this.selectedUsers.filter(filterUsersFn)
|
||||||
|
|
||||||
applyAction(filtered, deleteRightFn)
|
applyAction(filtered, deleteRightFn)
|
||||||
},
|
},
|
||||||
activate: () => {
|
activate: () => {
|
||||||
const filtered = this.selectedUsers.filter(user => user.deactivated && this.$store.state.user.id !== user.id)
|
const filtered = this.selectedUsers.filter(user => user.nickname && user.id && user.deactivated && this.$store.state.user.id !== user.id)
|
||||||
const activateUsersFn = async(users) => await this.$store.dispatch('ActivateUsers', { users })
|
const activateUsersFn = async(users) => await this.$store.dispatch('ActivateUsers', { users })
|
||||||
|
|
||||||
applyAction(filtered, activateUsersFn)
|
applyAction(filtered, activateUsersFn)
|
||||||
},
|
},
|
||||||
deactivate: () => {
|
deactivate: () => {
|
||||||
const filtered = this.selectedUsers.filter(user => !user.deactivated && this.$store.state.user.id !== user.id)
|
const filtered = this.selectedUsers.filter(user => user.nickname && user.id && !user.deactivated && this.$store.state.user.id !== user.id)
|
||||||
const deactivateUsersFn = async(users) => await this.$store.dispatch('DeactivateUsers', { users })
|
const deactivateUsersFn = async(users) => await this.$store.dispatch('DeactivateUsers', { users })
|
||||||
|
|
||||||
applyAction(filtered, deactivateUsersFn)
|
applyAction(filtered, deactivateUsersFn)
|
||||||
},
|
},
|
||||||
remove: () => {
|
remove: () => {
|
||||||
const filtered = this.selectedUsers.filter(user => this.$store.state.user.id !== user.id)
|
const filtered = this.selectedUsers.filter(user => user.nickname && user.id && this.$store.state.user.id !== user.id)
|
||||||
const deleteAccountFn = async(users) => await this.$store.dispatch('DeleteUsers', { users })
|
const deleteAccountFn = async(users) => await this.$store.dispatch('DeleteUsers', { users })
|
||||||
|
|
||||||
applyAction(filtered, deleteAccountFn)
|
applyAction(filtered, deleteAccountFn)
|
||||||
|
@ -199,34 +199,34 @@ export default {
|
||||||
addTag: (tag) => () => {
|
addTag: (tag) => () => {
|
||||||
const filtered = this.selectedUsers.filter(user =>
|
const filtered = this.selectedUsers.filter(user =>
|
||||||
tag === 'disable_remote_subscription' || tag === 'disable_any_subscription'
|
tag === 'disable_remote_subscription' || tag === 'disable_any_subscription'
|
||||||
? user.local && !user.tags.includes(tag)
|
? user.nickname && user.id && user.local && !user.tags.includes(tag)
|
||||||
: !user.tags.includes(tag))
|
: user.nickname && user.id && !user.tags.includes(tag))
|
||||||
const addTagFn = async(users) => await this.$store.dispatch('AddTag', { users, tag })
|
const addTagFn = async(users) => await this.$store.dispatch('AddTag', { users, tag })
|
||||||
applyAction(filtered, addTagFn)
|
applyAction(filtered, addTagFn)
|
||||||
},
|
},
|
||||||
removeTag: (tag) => async() => {
|
removeTag: (tag) => async() => {
|
||||||
const filtered = this.selectedUsers.filter(user =>
|
const filtered = this.selectedUsers.filter(user =>
|
||||||
tag === 'disable_remote_subscription' || tag === 'disable_any_subscription'
|
tag === 'disable_remote_subscription' || tag === 'disable_any_subscription'
|
||||||
? user.local && user.tags.includes(tag)
|
? user.nickname && user.id && user.local && user.tags.includes(tag)
|
||||||
: user.tags.includes(tag))
|
: user.nickname && user.id && user.tags.includes(tag))
|
||||||
const removeTagFn = async(users) => await this.$store.dispatch('RemoveTag', { users, tag })
|
const removeTagFn = async(users) => await this.$store.dispatch('RemoveTag', { users, tag })
|
||||||
|
|
||||||
applyAction(filtered, removeTagFn)
|
applyAction(filtered, removeTagFn)
|
||||||
},
|
},
|
||||||
requirePasswordReset: () => {
|
requirePasswordReset: () => {
|
||||||
const filtered = this.selectedUsers.filter(user => user.local)
|
const filtered = this.selectedUsers.filter(user => user.nickname && user.id && user.local)
|
||||||
const requirePasswordResetFn = async(users) => await this.$store.dispatch('RequirePasswordReset', users)
|
const requirePasswordResetFn = async(users) => await this.$store.dispatch('RequirePasswordReset', users)
|
||||||
|
|
||||||
applyAction(filtered, requirePasswordResetFn)
|
applyAction(filtered, requirePasswordResetFn)
|
||||||
},
|
},
|
||||||
confirmAccounts: () => {
|
confirmAccounts: () => {
|
||||||
const filtered = this.selectedUsers.filter(user => user.local && user.confirmation_pending)
|
const filtered = this.selectedUsers.filter(user => user.nickname && user.id && user.local && user.confirmation_pending)
|
||||||
const confirmAccountFn = async(users) => await this.$store.dispatch('ConfirmUsersEmail', { users })
|
const confirmAccountFn = async(users) => await this.$store.dispatch('ConfirmUsersEmail', { users })
|
||||||
|
|
||||||
applyAction(filtered, confirmAccountFn)
|
applyAction(filtered, confirmAccountFn)
|
||||||
},
|
},
|
||||||
resendConfirmation: () => {
|
resendConfirmation: () => {
|
||||||
const filtered = this.selectedUsers.filter(user => user.local && user.confirmation_pending)
|
const filtered = this.selectedUsers.filter(user => user.nickname && user.id && user.local && user.confirmation_pending)
|
||||||
const resendConfirmationFn = async(users) => await this.$store.dispatch('ResendConfirmationEmail', users)
|
const resendConfirmationFn = async(users) => await this.$store.dispatch('ResendConfirmationEmail', users)
|
||||||
|
|
||||||
applyAction(filtered, resendConfirmationFn)
|
applyAction(filtered, resendConfirmationFn)
|
||||||
|
|
|
@ -75,9 +75,11 @@
|
||||||
<el-table-column :label="$t('users.actions')" fixed="right">
|
<el-table-column :label="$t('users.actions')" fixed="right">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<moderation-dropdown
|
<moderation-dropdown
|
||||||
|
v-if="validUser(scope.row)"
|
||||||
:user="scope.row"
|
:user="scope.row"
|
||||||
:page="'users'"
|
:page="'users'"
|
||||||
@open-reset-token-dialog="openResetPasswordDialog"/>
|
@open-reset-token-dialog="openResetPasswordDialog"/>
|
||||||
|
<span v-else class="invalid-user">{{ $t('users.invalidUser') }}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
@ -140,12 +142,6 @@ export default {
|
||||||
normalizedUsersCount() {
|
normalizedUsersCount() {
|
||||||
return numeral(this.$store.state.users.totalUsersCount).format('0a')
|
return numeral(this.$store.state.users.totalUsersCount).format('0a')
|
||||||
},
|
},
|
||||||
users() {
|
|
||||||
return this.$store.state.users.fetchedUsers
|
|
||||||
},
|
|
||||||
usersCount() {
|
|
||||||
return this.$store.state.users.totalUsersCount
|
|
||||||
},
|
|
||||||
pageSize() {
|
pageSize() {
|
||||||
return this.$store.state.users.pageSize
|
return this.$store.state.users.pageSize
|
||||||
},
|
},
|
||||||
|
@ -164,6 +160,12 @@ export default {
|
||||||
isMobile() {
|
isMobile() {
|
||||||
return this.$store.state.app.device === 'mobile'
|
return this.$store.state.app.device === 'mobile'
|
||||||
},
|
},
|
||||||
|
users() {
|
||||||
|
return this.$store.state.users.fetchedUsers
|
||||||
|
},
|
||||||
|
usersCount() {
|
||||||
|
return this.$store.state.users.totalUsersCount
|
||||||
|
},
|
||||||
width() {
|
width() {
|
||||||
return this.isMobile ? 55 : false
|
return this.isMobile ? 55 : false
|
||||||
}
|
}
|
||||||
|
@ -211,6 +213,9 @@ export default {
|
||||||
},
|
},
|
||||||
showDeactivatedButton(id) {
|
showDeactivatedButton(id) {
|
||||||
return this.$store.state.user.id !== id
|
return this.$store.state.user.id !== id
|
||||||
|
},
|
||||||
|
validUser(user) {
|
||||||
|
return user.nickname && user.id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -248,6 +253,9 @@ export default {
|
||||||
.create-account > .el-icon-plus {
|
.create-account > .el-icon-plus {
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
}
|
}
|
||||||
|
.invalid-user {
|
||||||
|
color: gray;
|
||||||
|
}
|
||||||
.users-header-container {
|
.users-header-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="left-header-container">
|
<div class="left-header-container">
|
||||||
<moderation-dropdown
|
<moderation-dropdown
|
||||||
|
v-if="validUser(user)"
|
||||||
:user="user"
|
:user="user"
|
||||||
:page="'userPage'"
|
:page="'userPage'"
|
||||||
@open-reset-token-dialog="openResetPasswordDialog"/>
|
@open-reset-token-dialog="openResetPasswordDialog"/>
|
||||||
|
@ -22,6 +23,7 @@
|
||||||
<reboot-button/>
|
<reboot-button/>
|
||||||
</header>
|
</header>
|
||||||
<moderation-dropdown
|
<moderation-dropdown
|
||||||
|
v-if="validUser(user)"
|
||||||
:user="user"
|
:user="user"
|
||||||
:page="'userPage'"
|
:page="'userPage'"
|
||||||
@open-reset-token-dialog="openResetPasswordDialog"/>
|
@open-reset-token-dialog="openResetPasswordDialog"/>
|
||||||
|
@ -182,6 +184,9 @@ export default {
|
||||||
},
|
},
|
||||||
openResetPasswordDialog() {
|
openResetPasswordDialog() {
|
||||||
this.resetPasswordDialogOpen = true
|
this.resetPasswordDialogOpen = true
|
||||||
|
},
|
||||||
|
validUser(user) {
|
||||||
|
return user.nickname && user.id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue