mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-05-07 14:07:00 +02:00
feat(users): add ban reason when admin banned a user
This commit is contained in:
@@ -7,11 +7,11 @@
|
||||
|
||||
UserController.$inject = ['$scope', '$state', '$window', 'Authentication', 'userResolve', 'Notification', 'NotifycationService', 'MeanTorrentConfig',
|
||||
'AdminService', 'ScoreLevelService', 'DebugConsoleService', 'TorrentGetInfoServices', 'SideOverlay', 'MakerGroupService', '$filter', '$translate',
|
||||
'marked'];
|
||||
'marked', 'ModalConfirmService'];
|
||||
|
||||
function UserController($scope, $state, $window, Authentication, user, Notification, NotifycationService, MeanTorrentConfig,
|
||||
AdminService, ScoreLevelService, mtDebug, TorrentGetInfoServices, SideOverlay, MakerGroupService, $filter, $translate,
|
||||
marked) {
|
||||
marked, ModalConfirmService) {
|
||||
var vm = this;
|
||||
vm.TGI = TorrentGetInfoServices;
|
||||
vm.authentication = Authentication;
|
||||
@@ -326,12 +326,47 @@
|
||||
*/
|
||||
vm.onUserStatusChanged = function () {
|
||||
var user = vm.user;
|
||||
AdminService.setUserStatus({
|
||||
userId: user._id,
|
||||
userStatus: vm.selectedStatus
|
||||
})
|
||||
.then(onSuccess)
|
||||
.catch(onError);
|
||||
|
||||
if (vm.selectedStatus === 'banned') {
|
||||
var modalOptions = {
|
||||
closeButtonText: $translate.instant('BANNED.CONFIRM_CANCEL'),
|
||||
actionButtonText: $translate.instant('BANNED.CONFIRM_OK'),
|
||||
headerText: $translate.instant('BANNED.CONFIRM_HEADER_TEXT'),
|
||||
bodyText: $translate.instant('BANNED.CONFIRM_BODY_TEXT', {uname: user.displayName}),
|
||||
|
||||
selectOptions: {
|
||||
enable: true,
|
||||
title: 'BANNED.REASON_TITLE',
|
||||
options: [
|
||||
'BANNED.REASON_ILLEGAL_SIGN_IN',
|
||||
'BANNED.REASON_ACCOUNT_TRADE',
|
||||
'BANNED.REASON_EXAMINATION_NOT_FINISHED',
|
||||
'BANNED.REASON_VIOLATED_RULES'
|
||||
]
|
||||
}
|
||||
};
|
||||
ModalConfirmService.showModal({}, modalOptions)
|
||||
.then(function (result) {
|
||||
var reason = result.reason;
|
||||
if (reason === 'CUSTOM') reason = result.custom;
|
||||
|
||||
AdminService.setUserStatus({
|
||||
userId: user._id,
|
||||
userStatus: vm.selectedStatus,
|
||||
banReason: reason
|
||||
})
|
||||
.then(onSuccess)
|
||||
.catch(onError);
|
||||
});
|
||||
} else {
|
||||
AdminService.setUserStatus({
|
||||
userId: user._id,
|
||||
userStatus: vm.selectedStatus,
|
||||
banReason: ''
|
||||
})
|
||||
.then(onSuccess)
|
||||
.catch(onError);
|
||||
}
|
||||
|
||||
function onSuccess(response) {
|
||||
vm.user = response;
|
||||
|
||||
@@ -193,7 +193,7 @@
|
||||
}
|
||||
|
||||
function onUserSigninError(response) {
|
||||
NotifycationService.showErrorNotify(response.data.message, 'SIGN.SIGNIN_ERROR');
|
||||
NotifycationService.showErrorNotify(response.data.message, 'SIGN.SIGNIN_ERROR', {reason: $translate.instant(response.data.reason)});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -251,7 +251,8 @@
|
||||
url: '/api/users/:userId/status',
|
||||
params: {
|
||||
userId: '@userId',
|
||||
userStatus: '@userStatus'
|
||||
userStatus: '@userStatus',
|
||||
banReason: '@banReason'
|
||||
},
|
||||
interceptor: {response: removeCache}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user