Skip to content

Commit baea74d

Browse files
authored
Merge pull request #100 from Human-Connection/67-remove-ip-address-fields
67 Remove IP address fields (GDPR compliance)
2 parents bac4e91 + 8b5a841 commit baea74d

File tree

4 files changed

+66
-11
lines changed

4 files changed

+66
-11
lines changed

core/db.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,9 @@ exports.saveEntry = function(fields, callback){
200200
callback({email: "Email address already exists"});
201201
return;
202202
}else{
203-
let sql = "INSERT INTO entries (firstname, lastname, email, country, message, anon, ipv4, image, "
203+
let sql = "INSERT INTO entries (firstname, lastname, email, country, message, anon, image, "
204204
+ "created_at, updated_at, confirm_key, beta, newsletter, pax) "
205-
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
205+
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
206206

207207
// run the query
208208
connection.query(
@@ -214,7 +214,6 @@ exports.saveEntry = function(fields, callback){
214214
data.country,
215215
data.message,
216216
data.anon,
217-
data.ipv4,
218217
data.image,
219218
data.created_at,
220219
data.updated_at,

core/entryController.js

-6
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ exports.getAll = function(req, res) {
3131
obj.lastname = item.lastname;
3232
obj.message = item.message;
3333
obj.country = item.country;
34-
obj.ipv4 = item.ipv4;
35-
obj.ipv6 = item.ipv6;
3634
obj.email_confirmed = item.email_confirmed;
3735
obj.confirm_key = item.confirm_key;
3836
obj.status = item.status;
@@ -210,10 +208,6 @@ exports.createEntry = function(req, res) {
210208

211209
res.status(400).json(out);
212210
}else{
213-
// TODO: handle ipv6
214-
// bundle required stuff into fields
215-
fields["ipv4"] = req.ip;
216-
217211
if(hasFile){
218212
fields["image"] = files[0].path.replace(/^.*[\\\/]/, '');
219213

documentation/tables.sql

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ CREATE TABLE IF NOT EXISTS `entries` (
1212
`country` char(2) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1313
`message` text COLLATE utf8mb4_unicode_ci NOT NULL,
1414
`anon` int(1) DEFAULT '0',
15-
`ipv4` varchar(40) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1615
`image` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1716
`created_at` varchar(15) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1817
`updated_at` varchar(15) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
@@ -23,4 +22,4 @@ CREATE TABLE IF NOT EXISTS `entries` (
2322
`email_confirmed` int(1) DEFAULT '0',
2423
`status` int(1) DEFAULT '0',
2524
PRIMARY KEY (`id`)
26-
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
25+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
'use strict';
2+
3+
var dbm;
4+
var type;
5+
var seed;
6+
7+
/**
8+
* We receive the dbmigrate dependency from dbmigrate initially.
9+
* This enables us to not have to rely on NODE_PATH.
10+
*/
11+
exports.setup = function (options, seedLink) {
12+
dbm = options.dbmigrate;
13+
type = dbm.dataType;
14+
seed = seedLink;
15+
};
16+
17+
exports.up = function (db, callback) {
18+
db.removeColumn(
19+
'entries',
20+
'ipv4',
21+
function (err) {
22+
if (err) return callback(err);
23+
return callback();
24+
});
25+
db.removeColumn(
26+
'entries',
27+
'ipv6',
28+
function (err) {
29+
if (err) return callback(err);
30+
return callback();
31+
});
32+
};
33+
34+
exports.down = function (db, callback) {
35+
db.addColumn(
36+
'entries',
37+
'ipv4',
38+
{
39+
type: 'string',
40+
length: 30,
41+
defaultValue: null,
42+
},
43+
function (err) {
44+
if (err) return callback(err);
45+
return callback();
46+
});
47+
db.addColumn(
48+
'entries',
49+
'ipv6',
50+
{
51+
type: 'string',
52+
length: 60,
53+
defaultValue: null,
54+
},
55+
function (err) {
56+
if (err) return callback(err);
57+
return callback();
58+
});
59+
};
60+
61+
exports._meta = {
62+
'version': 1
63+
};

0 commit comments

Comments
 (0)