fix: update to use shortid for sub resub

This commit is contained in:
Mrugesh Mohapatra
2018-08-03 01:28:49 +05:30
committed by Stuart Taylor
parent 99b9e9e3ba
commit 4511e33716
4 changed files with 18 additions and 21 deletions

View File

@ -14,8 +14,8 @@ import { isEmail } from 'validator';
import path from 'path';
import loopback from 'loopback';
import _ from 'lodash';
import { ObjectId } from 'mongodb';
import jwt from 'jsonwebtoken';
import generate from 'nanoid/generate';
import { fixCompletedChallengeItem } from '../utils';
import { themes } from '../utils/themes';
@ -34,6 +34,8 @@ import {
const log = debugFactory('fcc:models:user');
const BROWNIEPOINTS_TIMEOUT = [1, 'hour'];
const nanoidCharSet =
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
const createEmailError = redirectTo => wrapHandledError(
new Error('email format is invalid'),
@ -237,7 +239,7 @@ module.exports = function(User) {
user.externalId = uuid();
}
if (!user.unsubscribeId) {
user.unsubscribeId = new ObjectId();
user.unsubscribeId = generate(nanoidCharSet, 20);
}
if (!user.progressTimestamps) {
@ -296,7 +298,7 @@ module.exports = function(User) {
}
if (!user.unsubscribeId) {
user.unsubscribeId = new ObjectId();
user.unsubscribeId = generate(nanoidCharSet, 20);
}
})
.ignoreElements();