src/lib/db.js
function deleteUser(username, done) {
  return getUser(username, function(getUserErr, user) {
    if (getUserErr) {
      return done(getUserErr);
    }

    if (!user) {
      return done(new Error(`user '${username}' not found`));
    }

    user.tokens.forEach((token) => token.destroy());
    user.groups.forEach((group) => { group.members.remove(user.id); group.save(); });
    user.leading.forEach((group) => { group.leaders.remove(user.id); group.save(); });
    user.destroy(done);
  });
}
function deleteUser(username, done) {
  return getUser(username, function(getUserErr, user) {
    if (getUserErr) {
      return done(getUserErr);
    }

    if (!user) {
      return done(new Error(`user '${username}' not found`));
    }

    user.tokens.forEach((token) => token.destroy());
    user.groups.forEach((group) => { group.members.remove(user.id); group.save(); });
    user.leading.forEach((group) => { group.leaders.remove(user.id); group.save(); });
    user.destroy(done);
  });
}
function deleteUser ( username , done ) { return getUser ( username , function ( getUserErr , user ) { if ( getUserErr ) { return done ( getUserErr ) ; } if ( ! user ) { return done ( new Error ( ` ${ username } ` ) ) ; } user . tokens . forEach ( ( token ) => token . destroy ( ) ) ; user . groups . forEach ( ( group ) => { group . members . remove ( user . id ) ; group . save ( ) ; } ) ; user . leading . forEach ( ( group ) => { group . leaders . remove ( user . id ) ; group . save ( ) ; } ) ; user . destroy ( done ) ; } ) ; }
Destroy a user. This also deletes all the user's tokens.

@param {String} username
@param {Function} done - done(err)
Destroy a user . This also deletes all the user s tokens .