Skip to content

Commit e9e7acf

Browse files
committed
cleanup
1 parent cf6cf1a commit e9e7acf

File tree

3 files changed

+35
-11
lines changed

3 files changed

+35
-11
lines changed

dist/breinify-unsubscribe.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@
1717
tokenCodeValidation: null,
1818
tokenCodeUnsubscribe: null,
1919

20+
check: function(token, code, callback) {
21+
if (typeof token !== 'string') {
22+
callback(new Error('token not configured'));
23+
return false;
24+
} else if (typeof code !== 'string') {
25+
callback(new Error('unsubscribe code not specified or found'));
26+
return false;
27+
} else {
28+
return true;
29+
}
30+
},
31+
2032
getValidationToken: function () {
2133
if (this.tokenCodeValidation === null) {
2234
this.tokenCodeValidation = this._determineValidationToken();
@@ -78,6 +90,10 @@
7890
var token = _private.getValidationToken();
7991
code = _private.getCode(code);
8092

93+
if (!_private.check(token, code, callback)) {
94+
return;
95+
}
96+
8197
$.ajax({
8298
'url': 'https://api.breinify.com/res/' + token,
8399
'type': 'GET',
@@ -105,11 +121,7 @@
105121
var token = _private.getUnsubscribeToken();
106122
code = _private.getCode(code);
107123

108-
if (typeof token !== 'string') {
109-
callback(new Error('unsubscribe token not configured'));
110-
return;
111-
} else if (typeof code !== 'string') {
112-
callback(new Error('unsubscribe code not specified or found'));
124+
if (!_private.check(token, code, callback)) {
113125
return;
114126
}
115127

dist/breinify-unsubscribe.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/plugins/Unsubscribe.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@
1717
tokenCodeValidation: null,
1818
tokenCodeUnsubscribe: null,
1919

20+
check: function(token, code, callback) {
21+
if (typeof token !== 'string') {
22+
callback(new Error('token not configured'));
23+
return false;
24+
} else if (typeof code !== 'string') {
25+
callback(new Error('unsubscribe code not specified or found'));
26+
return false;
27+
} else {
28+
return true;
29+
}
30+
},
31+
2032
getValidationToken: function () {
2133
if (this.tokenCodeValidation === null) {
2234
this.tokenCodeValidation = this._determineValidationToken();
@@ -78,6 +90,10 @@
7890
var token = _private.getValidationToken();
7991
code = _private.getCode(code);
8092

93+
if (!_private.check(token, code, callback)) {
94+
return;
95+
}
96+
8197
$.ajax({
8298
'url': 'https://api.breinify.com/res/' + token,
8399
'type': 'GET',
@@ -105,11 +121,7 @@
105121
var token = _private.getUnsubscribeToken();
106122
code = _private.getCode(code);
107123

108-
if (typeof token !== 'string') {
109-
callback(new Error('unsubscribe token not configured'));
110-
return;
111-
} else if (typeof code !== 'string') {
112-
callback(new Error('unsubscribe code not specified or found'));
124+
if (!_private.check(token, code, callback)) {
113125
return;
114126
}
115127

0 commit comments

Comments
 (0)