Skip to content

Commit bc72158

Browse files
author
Sachin Maheshwari
committed
auth0 changes
1 parent 934b622 commit bc72158

File tree

2 files changed

+113
-84
lines changed

2 files changed

+113
-84
lines changed

web-assets/auth0/dev-tenant/database/create.js

Lines changed: 105 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -26,83 +26,97 @@
2626
'at https://manage.auth0.com/#/connections/database';
2727
return callback(new Error(msg)); */
2828
function create(user, callback) {
29-
//console.log("landed here...................................");
30-
var countryObj = JSON.parse(user.user_metadata.country);
31-
var regSource = user.user_metadata.regSource;
32-
var utmSource = user.user_metadata.utmSource;
33-
var utmMedium = user.user_metadata.utmMedium;
34-
var utmCampaign = user.user_metadata.utmCampaign;
35-
var retUrl = user.user_metadata.returnUrl;
36-
var afterActivationURL = retUrl != null ? retUrl : "https://" + configuration.DOMAIN + "/home";
37-
if (regSource === configuration.REG_BUSINESS) {
38-
afterActivationURL = "https://connect." + configuration.DOMAIN;
39-
}
40-
var data = {
41-
"param": {
42-
"handle": user.username,
43-
"email": user.email,
44-
"credential": {
45-
"password": user.password
46-
},
47-
"firstName": user.user_metadata.firstName,
48-
"lastName": user.user_metadata.lastName,
49-
"country": {
50-
"code": countryObj.code,
51-
"isoAlpha3Code": countryObj.alpha3,
52-
"isoAlpha2Code": countryObj.alpha2
53-
},
54-
"regSource": regSource,
55-
"utmSource": utmSource,
56-
"utmMedium": utmMedium,
57-
"utmCampaign": utmCampaign,
58-
},
59-
"options": {
60-
"afterActivationURL": encodeURIComponent(afterActivationURL)
61-
}
62-
};
63-
//console.log("SignUp....", user, data);
64-
request.post({
65-
url: "https://api." + configuration.DOMAIN + "/v3/users",
66-
json: data
67-
//for more options check:
68-
//https://github.com/mikeal/request#requestoptions-callback
69-
}, function (err, response, body) {
70-
71-
// console.log(err);
72-
// console.log(response.statusCode);
73-
// console.log(body.result.content);
74-
75-
if (err) return callback(err);
76-
console.log(body.result.content);
77-
if (response.statusCode !== 200) {
78-
//return callback(new ValidationError("lock.fallback",body.result.content));
79-
const error_message = body.result.content;
80-
let code = "lock.fallback";
81-
82-
if (error_message.search("Handle may not contain a space") !== -1) {
83-
code = "handle_invalid_space";
84-
} else if (error_message.search("Length of Handle in character should be between 2 and 15") !== -1) {
85-
code = "handle_invalid_length";
86-
} else if (error_message.search("Please choose another handle, not starting with admin") !== -1) {
87-
code = "handle_invalid_startwith_admin";
88-
} else if (error_message.search('Handle may contain only letters, numbers and') !== -1) {
89-
code = "handle_invalid_constains_forbidden_char";
90-
} else if (error_message.search("Handle may not contain only punctuation") !== -1) {
91-
code = "handle_invalid_conatins_only_punctuation";
92-
} else if (error_message.search("The user already exists") !== -1) {
93-
code = "user_exists";
94-
} else if (error_message.search("has already been taken") !== -1) {
95-
code = "user_exists";
96-
}
29+
//console.log("landed here...................................");
30+
var countryObj = JSON.parse(user.user_metadata.country);
31+
var regSource = user.user_metadata.reg_source;
32+
var utmSource = user.user_metadata.utm_source;
33+
var utmMedium = user.user_metadata.utm_medium;
34+
var utmCampaign = user.user_metadata.utm_campaign;
35+
var retUrl = user.user_metadata.returnUrl;
36+
var afterActivationURL =
37+
retUrl !== null ? retUrl : "https://" + configuration.DOMAIN + "/home";
38+
if (regSource === configuration.REG_BUSINESS) {
39+
afterActivationURL = "https://connect." + configuration.DOMAIN;
40+
}
41+
var data = {
42+
param: {
43+
handle: user.username,
44+
email: user.email,
45+
credential: {
46+
password: user.password,
47+
},
48+
firstName: user.user_metadata.firstName,
49+
lastName: user.user_metadata.lastName,
50+
country: {
51+
code: countryObj.code,
52+
isoAlpha3Code: countryObj.alpha3,
53+
isoAlpha2Code: countryObj.alpha2,
54+
},
55+
regSource: regSource,
56+
utmSource: utmSource,
57+
utmMedium: utmMedium,
58+
utmCampaign: utmCampaign,
59+
},
60+
options: {
61+
afterActivationURL: encodeURIComponent(afterActivationURL),
62+
},
63+
};
64+
//console.log("SignUp....", user, data);
65+
request.post(
66+
{
67+
url: "https://api." + configuration.DOMAIN + "/v3/users",
68+
json: data,
69+
//for more options check:
70+
//https://github.com/mikeal/request#requestoptions-callback
71+
},
72+
function (err, response, body) {
73+
// console.log(err);
74+
// console.log(response.statusCode);
75+
// console.log(body.result.content);
9776

77+
if (err) return callback(err);
78+
console.log(body.result.content);
79+
if (response.statusCode !== 200) {
80+
//return callback(new ValidationError("lock.fallback",body.result.content));
81+
const error_message = body.result.content;
82+
let code = "lock.fallback";
9883

84+
if (error_message.search("Handle may not contain a space") !== -1) {
85+
code = "handle_invalid_space";
86+
} else if (
87+
error_message.search(
88+
"Length of Handle in character should be between 2 and 15"
89+
) !== -1
90+
) {
91+
code = "handle_invalid_length";
92+
} else if (
93+
error_message.search(
94+
"Please choose another handle, not starting with admin"
95+
) !== -1
96+
) {
97+
code = "handle_invalid_startwith_admin";
98+
} else if (
99+
error_message.search(
100+
"Handle may contain only letters, numbers and"
101+
) !== -1
102+
) {
103+
code = "handle_invalid_constains_forbidden_char";
104+
} else if (
105+
error_message.search("Handle may not contain only punctuation") !== -1
106+
) {
107+
code = "handle_invalid_conatins_only_punctuation";
108+
} else if (error_message.search("The user already exists") !== -1) {
109+
code = "user_exists";
110+
} else if (error_message.search("has already been taken") !== -1) {
111+
code = "user_exists";
112+
}
99113

100-
return callback(new ValidationError(code, error_message));
114+
return callback(new ValidationError(code, error_message));
101115

102-
//return callback(new Error(body.result.content));
103-
}
104-
//if (response.statusCode === 401) return callback();
105-
/* const Analytics = require('analytics-node');
116+
//return callback(new Error(body.result.content));
117+
}
118+
//if (response.statusCode === 401) return callback();
119+
/* const Analytics = require('analytics-node');
106120
const _ = require('lodash');
107121
var analytics = new Analytics('bkPtWMUMTYDhww2zsJluzxtdhtmSsyd9');
108122
analytics.identify({
@@ -116,9 +130,24 @@ function create(user, callback) {
116130
event: 'signUp',
117131
properties: _.omit(user, ['credential', 'password'])
118132
});*/
119-
callback(null);
120-
}); //end post request
121-
//callback(null);
133+
/* const ua = require('universal-analytics');
134+
let visitor = ua('UA-6340959-1');
135+
visitor.pageview("/signup").send();
136+
var eParams = {
137+
ec: "utmCode",
138+
ea: "tracking",
139+
el: "tracking",
140+
cn: utmCampaign,
141+
cm: utmMedium,
142+
cs: utmSource,
143+
dp: "/signup"
144+
};
145+
146+
visitor.event(eParams).send(); */
147+
callback(null);
148+
}
149+
); //end post request
150+
//callback(null);
122151
}
123152

124153
//}

web-assets/auth0/dev-tenant/universal-login.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@
8989
var languageDictionary;
9090
var language;
9191
var optionsObj = Array();
92-
var regSource = config.extraParams.regSource || null;
93-
var utmSource = config.extraParams.utmSource || null;
94-
var utmMedium = config.extraParams.utmMedium || null;
95-
var utmCampaign = config.extraParams.utmCampaign || null;
92+
var regSource = config.extraParams.reg_source || null;
93+
var utmSource = config.extraParams.utm_source || null;
94+
var utmMedium = config.extraParams.utm_medium || null;
95+
var utmCampaign = config.extraParams.utm_campaign || null;
9696
var retUrl = config.extraParams.returnUrl || null;
9797
var loginMode = config.extraParams.mode || 'signIn';
9898

@@ -249,7 +249,7 @@
249249
additionalSignUpFields: [
250250
{
251251
type: "hidden",
252-
name: "regSource",
252+
name: "reg_source",
253253
value: regSource
254254
},
255255
{
@@ -259,17 +259,17 @@
259259
},
260260
{
261261
type: "hidden",
262-
name: "utmSource",
262+
name: "utm_source",
263263
value: utmSource
264264
},
265265
{
266266
type: "hidden",
267-
name: "utmMedium",
267+
name: "utm_medium",
268268
value: utmMedium
269269
},
270270
{
271271
type: "hidden",
272-
name: "utmCampaign",
272+
name: "utm_campaign",
273273
value: utmCampaign
274274
},
275275
{

0 commit comments

Comments
 (0)