web-manager 2.1.34 → 2.1.37

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. package/index.js +9 -28
  2. package/lib/account.js +27 -0
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -240,23 +240,15 @@ function Manager() {
240
240
  user.getIdToken(false)
241
241
  .then(function(token) {
242
242
  var done;
243
- // fetch('https://us-central1-' + This.properties.options.libraries.firebase_app.config.projectId + '.cloudfunctions.net/bm_api', {
244
- // method: 'POST',
245
- // body: JSON.stringify({
246
- // authenticationToken: token,
247
- // command: 'signup-handler',
248
- // payload: {
249
- // newsletterSignUp: domLib.select('.auth-newsletter-input').getValue(),
250
- // affiliateCode: This.storage().get('auth.affiliateCode', '')
251
- // }
252
- // }),
253
- // })
254
- fetch('https://us-central1-' + This.properties.options.libraries.firebase_app.config.projectId + '.cloudfunctions.net/bm_signUpHandler', {
243
+ fetch('https://us-central1-' + This.properties.options.libraries.firebase_app.config.projectId + '.cloudfunctions.net/bm_api', {
255
244
  method: 'POST',
256
245
  body: JSON.stringify({
257
246
  authenticationToken: token,
258
- newsletterSignUp: domLib.select('.auth-newsletter-input').getValue(),
259
- affiliateCode: This.storage().get('auth.affiliateCode', '')
247
+ command: 'user:sign-up',
248
+ payload: {
249
+ newsletterSignUp: domLib.select('.auth-newsletter-input').getValue(),
250
+ affiliateCode: This.storage().get('auth.affiliateCode', ''),
251
+ }
260
252
  }),
261
253
  })
262
254
  .catch(function () {})
@@ -274,20 +266,6 @@ function Manager() {
274
266
  }
275
267
  }, 5000);
276
268
 
277
- // This.ajax().request({
278
- // url: 'https://us-central1-' + This.properties.options.libraries.firebase_app.config.projectId + '.cloudfunctions.net/bm_signUpHandler',
279
- // // url: 'http://localhost:5001/ultimate-jekyll/us-central1/bm_signUpHandler',
280
- // body: {
281
- // authenticationToken: token,
282
- // newsletterSignUp: domLib.select('.auth-newsletter-input').getValue(),
283
- // affiliateCode: This.storage().get('auth.affiliateCode', '')
284
- // },
285
- // timeout: 5000,
286
- // })
287
- // .always(function (response, status) {
288
- // // This.storage().set('notifications.lastSynced', new Date(0).toISOString())
289
- // _authHandle_in_normal(This, user);
290
- // });
291
269
  })
292
270
  .catch(function(error) {
293
271
  console.error(error);
@@ -1062,6 +1040,9 @@ function Manager() {
1062
1040
  // This.log('subscribe()');
1063
1041
  return new Promise(function(resolve, reject) {
1064
1042
  // var subscribed = !This.notifications().isSubscribed();
1043
+ if (!supported) {
1044
+ return resolve(false)
1045
+ }
1065
1046
  firebase.messaging().getToken({
1066
1047
  serviceWorkerRegistration: This.properties.references.serviceWorker,
1067
1048
  })
package/lib/account.js CHANGED
@@ -202,6 +202,12 @@ Account.prototype._resolveAccount = function (currentUser, account, options) {
202
202
 
203
203
  var defaultPlanId = options.defaultPlanId || 'basic';
204
204
 
205
+ // Resolve auth
206
+ account.auth = account.auth || {};
207
+ account.auth.email = account.auth.email || currentUser.email || null;
208
+ account.auth.uid = account.auth.uid || currentUser.uid || null;
209
+ account.auth.temporary = account.auth.temporary || false;
210
+
205
211
  // Resolve plan
206
212
  account.plan = account.plan || {};
207
213
  account.plan.id = account.plan.id || defaultPlanId;
@@ -254,6 +260,27 @@ Account.prototype._resolveAccount = function (currentUser, account, options) {
254
260
  account.roles.vip = account.roles.vip === true || account.roles.vip === 'true';
255
261
  account.roles.promoExempt = account.roles.promoExempt === true || account.roles.promoExempt === 'true';
256
262
 
263
+ // Resolve affiliate
264
+ account.affiliate = account.affiliate || {};
265
+ account.affiliate.code = account.affiliate.code || 'unknown';
266
+ account.affiliate.referrals = account.affiliate.referrals || [];
267
+ account.affiliate.referrer = account.affiliate.referrer || 'unknown';
268
+
269
+ // Resolve activity
270
+ account.activity = account.activity || {};
271
+ account.activity.lastActivity = account.activity.lastActivity || {};
272
+ account.activity.lastActivity.timestamp = account.activity.lastActivity.timestamp || '1999-01-01T00:00:00Z';
273
+ account.activity.lastActivity.timestampUNIX = account.activity.lastActivity.timestampUNIX || 0;
274
+
275
+ account.activity.created = account.activity.created || {};
276
+ account.activity.created.timestamp = account.activity.created.timestamp || '1999-01-01T00:00:00Z';
277
+ account.activity.created.timestampUNIX = account.activity.created.timestampUNIX || 0;
278
+
279
+ // Api
280
+ account.api = account.api || {};
281
+ account.api.clientId = account.api.clientId || 'unknown';
282
+ account.api.privateKey = account.api.privateKey || 'unknown';
283
+
257
284
  // Set UI elements
258
285
  try {
259
286
  var isDevelopment = utilities.get(self.Manager, 'properties.meta.environment', '') === 'development';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-manager",
3
- "version": "2.1.34",
3
+ "version": "2.1.37",
4
4
  "description": "Easily access important variables such as the query string, current domain, and current page in a single object.",
5
5
  "main": "index.js",
6
6
  "scripts": {