mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
log self account delete, logout on self account delete
This commit is contained in:
@@ -170,6 +170,7 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator'],
|
|||||||
if (err) {
|
if (err) {
|
||||||
app.alertError(err.message);
|
app.alertError(err.message);
|
||||||
}
|
}
|
||||||
|
app.logout();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -30,8 +30,6 @@ app.isConnected = false;
|
|||||||
|
|
||||||
socket.on('event:banned', onEventBanned);
|
socket.on('event:banned', onEventBanned);
|
||||||
|
|
||||||
socket.on('event:logout', app.logout);
|
|
||||||
|
|
||||||
socket.on('event:alert', app.alert);
|
socket.on('event:alert', app.alert);
|
||||||
|
|
||||||
function onConnect() {
|
function onConnect() {
|
||||||
|
|||||||
@@ -180,26 +180,27 @@ User.deleteUsers = function(socket, uids, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async.each(uids, function(uid, next) {
|
async.each(uids, function(uid, next) {
|
||||||
user.isAdministrator(uid, function(err, isAdmin) {
|
async.waterfall([
|
||||||
if (err || isAdmin) {
|
function (next) {
|
||||||
return callback(err || new Error('[[error:cant-delete-other-admins]]'));
|
user.isAdministrator(uid, next);
|
||||||
}
|
},
|
||||||
|
function (isAdmin, next) {
|
||||||
user.delete(uid, function(err) {
|
if (isAdmin) {
|
||||||
if (err) {
|
return next(new Error('[[error:cant-delete-other-admins]]'));
|
||||||
return next(err);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
user.delete(uid, next);
|
||||||
|
},
|
||||||
|
function (next) {
|
||||||
events.log({
|
events.log({
|
||||||
type: 'user-delete',
|
type: 'user-delete',
|
||||||
uid: socket.uid,
|
uid: socket.uid,
|
||||||
targetUid: uid,
|
targetUid: uid,
|
||||||
ip: socket.ip
|
ip: socket.ip
|
||||||
});
|
});
|
||||||
|
|
||||||
next();
|
next();
|
||||||
});
|
}
|
||||||
});
|
], next);
|
||||||
}, callback);
|
}, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +1,20 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var async = require('async'),
|
var async = require('async');
|
||||||
|
|
||||||
|
|
||||||
user = require('../user'),
|
var user = require('../user');
|
||||||
topics = require('../topics'),
|
var topics = require('../topics');
|
||||||
notifications = require('../notifications'),
|
var notifications = require('../notifications');
|
||||||
messaging = require('../messaging'),
|
var messaging = require('../messaging');
|
||||||
plugins = require('../plugins'),
|
var plugins = require('../plugins');
|
||||||
utils = require('../../public/src/utils'),
|
var websockets = require('./index');
|
||||||
websockets = require('./index'),
|
var meta = require('../meta');
|
||||||
meta = require('../meta'),
|
var events = require('../events');
|
||||||
events = require('../events'),
|
var emailer = require('../emailer');
|
||||||
emailer = require('../emailer'),
|
var db = require('../database');
|
||||||
db = require('../database'),
|
|
||||||
|
|
||||||
SocketUser = {};
|
var SocketUser = {};
|
||||||
|
|
||||||
|
|
||||||
require('./user/profile')(SocketUser);
|
require('./user/profile')(SocketUser);
|
||||||
@@ -33,20 +32,29 @@ SocketUser.deleteAccount = function(socket, data, callback) {
|
|||||||
if (!socket.uid) {
|
if (!socket.uid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
user.isAdministrator(socket.uid, function(err, isAdmin) {
|
|
||||||
if (err || isAdmin) {
|
|
||||||
return callback(err || new Error('[[error:cant-delete-admin]]'));
|
|
||||||
}
|
|
||||||
|
|
||||||
socket.broadcast.emit('event:user_status_change', {uid: socket.uid, status: 'offline'});
|
async.waterfall([
|
||||||
user.deleteAccount(socket.uid, function(err) {
|
function (next) {
|
||||||
if (err) {
|
user.isAdministrator(socket.uid, next);
|
||||||
return callback(err);
|
},
|
||||||
|
function (isAdmin, next) {
|
||||||
|
if (isAdmin) {
|
||||||
|
return next(new Error('[[error:cant-delete-admin]]'));
|
||||||
}
|
}
|
||||||
websockets.in('uid_' + socket.uid).emit('event:logout');
|
user.deleteAccount(socket.uid, next);
|
||||||
callback();
|
},
|
||||||
});
|
function (next) {
|
||||||
});
|
socket.broadcast.emit('event:user_status_change', {uid: socket.uid, status: 'offline'});
|
||||||
|
|
||||||
|
events.log({
|
||||||
|
type: 'user-delete',
|
||||||
|
uid: socket.uid,
|
||||||
|
targetUid: socket.uid,
|
||||||
|
ip: socket.ip
|
||||||
|
});
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
], callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
SocketUser.emailExists = function(socket, data, callback) {
|
SocketUser.emailExists = function(socket, data, callback) {
|
||||||
@@ -271,7 +279,7 @@ SocketUser.invite = function(socket, email, callback) {
|
|||||||
return callback(new Error('[[error:invalid-data]]'));
|
return callback(new Error('[[error:invalid-data]]'));
|
||||||
}
|
}
|
||||||
|
|
||||||
var registrationType = meta.config.registrationType
|
var registrationType = meta.config.registrationType;
|
||||||
|
|
||||||
if (registrationType !== 'invite-only' && registrationType !== 'admin-invite-only') {
|
if (registrationType !== 'invite-only' && registrationType !== 'admin-invite-only') {
|
||||||
return callback(new Error('[[error:forum-not-invite-only]]'));
|
return callback(new Error('[[error:forum-not-invite-only]]'));
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
<div class="avatar avatar-sm" style="background-color: {events.user.icon:bgColor};">{events.user.icon:text}</div>
|
<div class="avatar avatar-sm" style="background-color: {events.user.icon:bgColor};">{events.user.icon:text}</div>
|
||||||
<!-- ENDIF events.user.picture -->
|
<!-- ENDIF events.user.picture -->
|
||||||
</a>
|
</a>
|
||||||
<a href="{config.relative_path}/user/{events.user.userslug}" target="_blank">{events.user.username}</a> (uid {events.user.uid}) (IP {events.ip})
|
<a href="{config.relative_path}/user/{events.user.userslug}" target="_blank">{events.user.username}</a> (uid {events.uid}) (IP {events.ip})
|
||||||
<span class="pull-right">{events.timestampISO}</span>
|
<span class="pull-right">{events.timestampISO}</span>
|
||||||
<br /><br />
|
<br /><br />
|
||||||
<pre>{events.jsonString}</pre>
|
<pre>{events.jsonString}</pre>
|
||||||
|
|||||||
Reference in New Issue
Block a user