kopia lustrzana https://github.com/c9/core
Merge pull request +13391 from c9/multi-soft-block-signup
Soft block throwaway emails on signuppull/290/head
commit
17106993ab
|
@ -10,17 +10,16 @@ define(function(require, exports, module) {
|
|||
var hasInternalDomain = require("c9/has-internal-domain");
|
||||
var hasInternalTestName = require("c9/has-internal-test-name");
|
||||
|
||||
function skipAnalytics(userId, name, email, allowUnauthorized) {
|
||||
|
||||
function skipAnalytics(userId, name, email, blocked, allowUnauthorized) {
|
||||
if (!userId) return true; // users without an id should never reach the Segment library
|
||||
|
||||
if (typeof userId == "object") {
|
||||
var user = userId;
|
||||
return skipAnalytics(user.id, user.name || user.username, user.email, name); // make it backwards compatible for the client
|
||||
return skipAnalytics(user.id, user.name || user.username, user.email, user.blocked, name); // make it backwards compatible for the client
|
||||
}
|
||||
|
||||
if (!allowUnauthorized && userId === -1) return true;
|
||||
|
||||
|
||||
if (blocked) return true;
|
||||
if (hasInternalTestName(name)) return true;
|
||||
if (hasInternalDomain(email)) return true;
|
||||
return false;
|
||||
|
|
|
@ -68,6 +68,16 @@ describe("skip-analytics", function() {
|
|||
user.email = "test@cloud9beta.com";
|
||||
assert.equal(true, skipAnalytics(user), "skipAnalytics should return true when user has internal beta email");
|
||||
});
|
||||
|
||||
it("returns true when user is marked as blocked", function() {
|
||||
var user = {
|
||||
id: faker.random.uuid(),
|
||||
email: faker.internet.email(),
|
||||
blocked: "soft ban foo"
|
||||
};
|
||||
|
||||
assert.equal(true, skipAnalytics(user), "skipAnalytics should return true when user is marked as blocked");
|
||||
});
|
||||
|
||||
it("returns false when user is authorized and does not have intermal email", function() {
|
||||
var user = {
|
||||
|
|
Ładowanie…
Reference in New Issue