| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862 |
- /* eslint-disable no-use-before-define */
- const debug = require('debug')('growi:models:user');
- const logger = require('@alias/logger')('growi:models:user');
- const path = require('path');
- const mongoose = require('mongoose');
- const uniqueValidator = require('mongoose-unique-validator');
- const mongoosePaginate = require('mongoose-paginate');
- const ObjectId = mongoose.Schema.Types.ObjectId;
- const crypto = require('crypto');
- const async = require('async');
- module.exports = function(crowi) {
- const STATUS_REGISTERED = 1;
- const STATUS_ACTIVE = 2;
- const STATUS_SUSPENDED = 3;
- const STATUS_DELETED = 4;
- const STATUS_INVITED = 5;
- const USER_PUBLIC_FIELDS = '_id image isEmailPublished isGravatarEnabled googleId name username email introduction status lang createdAt admin';
- const IMAGE_POPULATION = { path: 'imageAttachment', select: 'filePathProxied' };
- const LANG_EN = 'en';
- const LANG_EN_US = 'en-US';
- const LANG_EN_GB = 'en-GB';
- const LANG_JA = 'ja';
- const PAGE_ITEMS = 50;
- let userEvent;
- // init event
- if (crowi != null) {
- userEvent = crowi.event('user');
- userEvent.on('activated', userEvent.onActivated);
- }
- const userSchema = new mongoose.Schema({
- userId: String,
- image: String,
- imageAttachment: { type: ObjectId, ref: 'Attachment' },
- isGravatarEnabled: { type: Boolean, default: false },
- isEmailPublished: { type: Boolean, default: true },
- googleId: String,
- name: { type: String },
- username: { type: String, required: true, unique: true },
- email: { type: String, unique: true, sparse: true },
- // === The official settings
- // username: { type: String, index: true },
- // email: { type: String, required: true, index: true },
- // === crowi-plus (>= 2.1.0, <2.3.0) settings
- // email: { type: String, required: true, unique: true },
- introduction: { type: String },
- password: String,
- apiToken: String,
- lang: {
- type: String,
- // eslint-disable-next-line no-eval
- enum: Object.keys(getLanguageLabels()).map((k) => { return eval(k) }),
- default: LANG_EN_US,
- },
- status: {
- type: Number, required: true, default: STATUS_ACTIVE, index: true,
- },
- createdAt: { type: Date, default: Date.now },
- lastLoginAt: { type: Date },
- admin: { type: Boolean, default: 0, index: true },
- });
- userSchema.plugin(mongoosePaginate);
- userSchema.plugin(uniqueValidator);
- function validateCrowi() {
- if (crowi == null) {
- throw new Error('"crowi" is null. Init User model with "crowi" argument first.');
- }
- }
- function decideUserStatusOnRegistration() {
- validateCrowi();
- const { configManager, aclService } = crowi;
- const isInstalled = configManager.getConfig('crowi', 'app:installed');
- if (!isInstalled) {
- return STATUS_ACTIVE; // is this ok?
- }
- // status decided depends on registrationMode
- const registrationMode = configManager.getConfig('crowi', 'security:registrationMode');
- switch (registrationMode) {
- case aclService.labels.SECURITY_REGISTRATION_MODE_OPEN:
- return STATUS_ACTIVE;
- case aclService.labels.SECURITY_REGISTRATION_MODE_RESTRICTED:
- case aclService.labels.SECURITY_REGISTRATION_MODE_CLOSED: // 一応
- return STATUS_REGISTERED;
- default:
- return STATUS_ACTIVE; // どっちにすんのがいいんだろうな
- }
- }
- function generateRandomEmail() {
- const randomstr = generateRandomTempPassword();
- return `change-it-${randomstr}@example.com`;
- }
- function generateRandomTempPassword() {
- const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!=-_';
- let password = '';
- const len = 12;
- for (let i = 0; i < len; i++) {
- const randomPoz = Math.floor(Math.random() * chars.length);
- password += chars.substring(randomPoz, randomPoz + 1);
- }
- return password;
- }
- function generatePassword(password) {
- validateCrowi();
- const hasher = crypto.createHash('sha256');
- hasher.update(crowi.env.PASSWORD_SEED + password);
- return hasher.digest('hex');
- }
- function generateApiToken(user) {
- const hasher = crypto.createHash('sha256');
- hasher.update((new Date()).getTime() + user._id);
- return hasher.digest('base64');
- }
- function getLanguageLabels() {
- const lang = {};
- lang.LANG_EN = LANG_EN;
- lang.LANG_EN_US = LANG_EN_US;
- lang.LANG_EN_GB = LANG_EN_GB;
- lang.LANG_JA = LANG_JA;
- return lang;
- }
- userSchema.methods.populateImage = async function() {
- // eslint-disable-next-line no-return-await
- return await this.populate(IMAGE_POPULATION);
- };
- userSchema.methods.isPasswordSet = function() {
- if (this.password) {
- return true;
- }
- return false;
- };
- userSchema.methods.isPasswordValid = function(password) {
- return this.password === generatePassword(password);
- };
- userSchema.methods.setPassword = function(password) {
- this.password = generatePassword(password);
- return this;
- };
- userSchema.methods.isEmailSet = function() {
- if (this.email) {
- return true;
- }
- return false;
- };
- userSchema.methods.updateLastLoginAt = function(lastLoginAt, callback) {
- this.lastLoginAt = lastLoginAt;
- this.save((err, userData) => {
- return callback(err, userData);
- });
- };
- userSchema.methods.updateIsGravatarEnabled = function(isGravatarEnabled, callback) {
- this.isGravatarEnabled = isGravatarEnabled;
- this.save((err, userData) => {
- return callback(err, userData);
- });
- };
- userSchema.methods.updateIsEmailPublished = function(isEmailPublished, callback) {
- this.isEmailPublished = isEmailPublished;
- this.save((err, userData) => {
- return callback(err, userData);
- });
- };
- userSchema.methods.updatePassword = function(password, callback) {
- this.setPassword(password);
- this.save((err, userData) => {
- return callback(err, userData);
- });
- };
- userSchema.methods.canDeleteCompletely = function(creatorId) {
- const pageCompleteDeletionAuthority = crowi.configManager.getConfig('crowi', 'security:pageCompleteDeletionAuthority');
- if (this.admin) {
- return true;
- }
- if (pageCompleteDeletionAuthority === 'anyOne' || pageCompleteDeletionAuthority == null) {
- return true;
- }
- if (pageCompleteDeletionAuthority === 'adminAndAuthor') {
- return (this._id.equals(creatorId));
- }
- return false;
- };
- userSchema.methods.updateApiToken = function(callback) {
- const self = this;
- self.apiToken = generateApiToken(this);
- return new Promise(((resolve, reject) => {
- self.save((err, userData) => {
- if (err) {
- return reject(err);
- }
- return resolve(userData);
- });
- }));
- };
- userSchema.methods.updateImage = async function(attachment) {
- this.imageAttachment = attachment;
- return this.save();
- };
- userSchema.methods.deleteImage = async function() {
- validateCrowi();
- const Attachment = crowi.model('Attachment');
- // the 'image' field became DEPRECATED in v3.3.8
- this.image = undefined;
- if (this.imageAttachment != null) {
- Attachment.removeWithSubstanceById(this.imageAttachment._id);
- }
- this.imageAttachment = undefined;
- return this.save();
- };
- userSchema.methods.updateGoogleId = function(googleId, callback) {
- this.googleId = googleId;
- this.save((err, userData) => {
- return callback(err, userData);
- });
- };
- userSchema.methods.deleteGoogleId = function(callback) {
- return this.updateGoogleId(null, callback);
- };
- userSchema.methods.activateInvitedUser = async function(username, name, password) {
- this.setPassword(password);
- this.name = name;
- this.username = username;
- this.status = STATUS_ACTIVE;
- this.save((err, userData) => {
- userEvent.emit('activated', userData);
- if (err) {
- throw new Error(err);
- }
- return userData;
- });
- };
- userSchema.methods.removeFromAdmin = function(callback) {
- debug('Remove from admin', this);
- this.admin = 0;
- this.save((err, userData) => {
- return callback(err, userData);
- });
- };
- userSchema.methods.makeAdmin = function(callback) {
- debug('Admin', this);
- this.admin = 1;
- this.save((err, userData) => {
- return callback(err, userData);
- });
- };
- userSchema.methods.asyncMakeAdmin = async function(callback) {
- this.admin = 1;
- return this.save();
- };
- userSchema.methods.statusActivate = function(callback) {
- debug('Activate User', this);
- this.status = STATUS_ACTIVE;
- this.save((err, userData) => {
- userEvent.emit('activated', userData);
- return callback(err, userData);
- });
- };
- userSchema.methods.statusSuspend = function(callback) {
- debug('Suspend User', this);
- this.status = STATUS_SUSPENDED;
- if (this.email === undefined || this.email === null) { // migrate old data
- this.email = '-';
- }
- if (this.name === undefined || this.name === null) { // migrate old data
- this.name = `-${Date.now()}`;
- }
- if (this.username === undefined || this.usename === null) { // migrate old data
- this.username = '-';
- }
- this.save((err, userData) => {
- return callback(err, userData);
- });
- };
- userSchema.methods.statusDelete = function(callback) {
- debug('Delete User', this);
- const now = new Date();
- const deletedLabel = `deleted_at_${now.getTime()}`;
- this.status = STATUS_DELETED;
- this.username = deletedLabel;
- this.password = '';
- this.name = '';
- this.email = `${deletedLabel}@deleted`;
- this.googleId = null;
- this.isGravatarEnabled = false;
- this.image = null;
- this.save((err, userData) => {
- return callback(err, userData);
- });
- };
- userSchema.methods.updateGoogleId = function(googleId, callback) {
- this.googleId = googleId;
- this.save((err, userData) => {
- return callback(err, userData);
- });
- };
- userSchema.statics.getLanguageLabels = getLanguageLabels;
- userSchema.statics.getUserStatusLabels = function() {
- const userStatus = {};
- userStatus[STATUS_REGISTERED] = 'Approval Pending';
- userStatus[STATUS_ACTIVE] = 'Active';
- userStatus[STATUS_SUSPENDED] = 'Suspended';
- userStatus[STATUS_DELETED] = 'Deleted';
- userStatus[STATUS_INVITED] = 'Invited';
- return userStatus;
- };
- userSchema.statics.isEmailValid = function(email, callback) {
- validateCrowi();
- const whitelist = crowi.configManager.getConfig('crowi', 'security:registrationWhiteList');
- if (Array.isArray(whitelist) && whitelist.length > 0) {
- return whitelist.some((allowedEmail) => {
- const re = new RegExp(`${allowedEmail}$`);
- return re.test(email);
- });
- }
- return true;
- };
- userSchema.statics.filterToPublicFields = function(user) {
- debug('User is', typeof user, user);
- if (typeof user !== 'object' || !user._id) {
- return user;
- }
- const filteredUser = {};
- const fields = USER_PUBLIC_FIELDS.split(' ');
- for (let i = 0; i < fields.length; i++) {
- const key = fields[i];
- if (user[key]) {
- filteredUser[key] = user[key];
- }
- }
- return filteredUser;
- };
- userSchema.statics.findUsers = function(options, callback) {
- const sort = options.sort || { status: 1, createdAt: 1 };
- this.find()
- .sort(sort)
- .skip(options.skip || 0)
- .limit(options.limit || 21)
- .exec((err, userData) => {
- callback(err, userData);
- });
- };
- userSchema.statics.findAllUsers = function(option) {
- // eslint-disable-next-line no-param-reassign
- option = option || {};
- const sort = option.sort || { createdAt: -1 };
- const fields = option.fields || USER_PUBLIC_FIELDS;
- let status = option.status || [STATUS_ACTIVE, STATUS_SUSPENDED];
- if (!Array.isArray(status)) {
- status = [status];
- }
- return this.find()
- .or(status.map((s) => { return { status: s } }))
- .select(fields)
- .sort(sort);
- };
- userSchema.statics.findUsersByIds = function(ids, option) {
- // eslint-disable-next-line no-param-reassign
- option = option || {};
- const sort = option.sort || { createdAt: -1 };
- const status = option.status || STATUS_ACTIVE;
- const fields = option.fields || USER_PUBLIC_FIELDS;
- return this.find({ _id: { $in: ids }, status })
- .select(fields)
- .sort(sort);
- };
- userSchema.statics.findAdmins = function(callback) {
- this.find({ admin: true })
- .exec((err, admins) => {
- debug('Admins: ', admins);
- callback(err, admins);
- });
- };
- userSchema.statics.findUsersWithPagination = async function(options) {
- const sort = options.sort || { status: 1, username: 1, createdAt: 1 };
- // eslint-disable-next-line no-return-await
- return await this.paginate({ status: { $ne: STATUS_DELETED } }, { page: options.page || 1, limit: options.limit || PAGE_ITEMS }, (err, result) => {
- if (err) {
- debug('Error on pagination:', err);
- throw new Error(err);
- }
- return result;
- }, { sortBy: sort });
- };
- userSchema.statics.findUsersByPartOfEmail = function(emailPart, options) {
- const status = options.status || null;
- const emailPartRegExp = new RegExp(emailPart.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&'));
- const User = this;
- return new Promise((resolve, reject) => {
- const query = User.find({ email: emailPartRegExp }, USER_PUBLIC_FIELDS);
- if (status) {
- query.and({ status });
- }
- query
- .limit(PAGE_ITEMS + 1)
- .exec((err, userData) => {
- if (err) {
- return reject(err);
- }
- return resolve(userData);
- });
- });
- };
- userSchema.statics.findUserByUsername = function(username) {
- if (username == null) {
- return Promise.resolve(null);
- }
- return this.findOne({ username });
- };
- userSchema.statics.findUserByApiToken = function(apiToken) {
- if (apiToken == null) {
- return Promise.resolve(null);
- }
- return this.findOne({ apiToken });
- };
- userSchema.statics.findUserByGoogleId = function(googleId, callback) {
- if (googleId == null) {
- callback(null, null);
- }
- this.findOne({ googleId }, (err, userData) => {
- callback(err, userData);
- });
- };
- userSchema.statics.findUserByUsernameOrEmail = function(usernameOrEmail, password, callback) {
- this.findOne()
- .or([
- { username: usernameOrEmail },
- { email: usernameOrEmail },
- ])
- .exec((err, userData) => {
- callback(err, userData);
- });
- };
- userSchema.statics.findUserByEmailAndPassword = function(email, password, callback) {
- const hashedPassword = generatePassword(password);
- this.findOne({ email, password: hashedPassword }, (err, userData) => {
- callback(err, userData);
- });
- };
- userSchema.statics.isUserCountExceedsUpperLimit = async function() {
- const { aclService } = crowi;
- const userUpperLimit = aclService.userUpperLimit();
- if (userUpperLimit === 0) {
- return false;
- }
- const activeUsers = await this.countListByStatus(STATUS_ACTIVE);
- if (userUpperLimit !== 0 && userUpperLimit <= activeUsers) {
- return true;
- }
- return false;
- };
- userSchema.statics.countListByStatus = async function(status) {
- const User = this;
- const conditions = { status };
- // TODO count は非推奨。mongoose のバージョンアップ後に countDocuments に変更する。
- return User.count(conditions);
- };
- userSchema.statics.isRegisterableUsername = async function(username) {
- let usernameUsable = true;
- const userData = await this.findOne({ username });
- if (userData) {
- usernameUsable = false;
- }
- return usernameUsable;
- };
- userSchema.statics.isRegisterable = function(email, username, callback) {
- const User = this;
- let emailUsable = true;
- let usernameUsable = true;
- // username check
- this.findOne({ username }, (err, userData) => {
- if (userData) {
- usernameUsable = false;
- }
- // email check
- User.findOne({ email }, (err, userData) => {
- if (userData) {
- emailUsable = false;
- }
- if (!emailUsable || !usernameUsable) {
- return callback(false, { email: emailUsable, username: usernameUsable });
- }
- return callback(true, {});
- });
- });
- };
- userSchema.statics.removeCompletelyById = function(id, callback) {
- const User = this;
- User.findById(id, (err, userData) => {
- if (!userData) {
- return callback(err, null);
- }
- debug('Removing user:', userData);
- // 物理削除可能なのは、承認待ちユーザー、招待中ユーザーのみ
- // 利用を一度開始したユーザーは論理削除のみ可能
- if (userData.status !== STATUS_REGISTERED && userData.status !== STATUS_INVITED) {
- return callback(new Error('Cannot remove completely the user whoes status is not INVITED'), null);
- }
- userData.remove((err) => {
- if (err) {
- return callback(err, null);
- }
- return callback(null, 1);
- });
- });
- };
- userSchema.statics.resetPasswordByRandomString = function(id) {
- const User = this;
- return new Promise(((resolve, reject) => {
- User.findById(id, (err, userData) => {
- if (!userData) {
- return reject(new Error('User not found'));
- }
- // is updatable check
- // if (userData.isUp
- const newPassword = generateRandomTempPassword();
- userData.setPassword(newPassword);
- userData.save((err, userData) => {
- if (err) {
- return reject(err);
- }
- resolve({ user: userData, newPassword });
- });
- });
- }));
- };
- userSchema.statics.createUsersByInvitation = function(emailList, toSendEmail, callback) {
- validateCrowi();
- const configManager = crowi.configManager;
- const User = this;
- const createdUserList = [];
- const mailer = crowi.getMailer();
- if (!Array.isArray(emailList)) {
- debug('emailList is not array');
- }
- async.each(
- emailList,
- (email, next) => {
- const newUser = new User();
- let tmpUsername;
- let password;
- // eslint-disable-next-line no-param-reassign
- email = email.trim();
- // email check
- // TODO: 削除済みはチェック対象から外そう〜
- User.findOne({ email }, (err, userData) => {
- // The user is exists
- if (userData) {
- createdUserList.push({
- email,
- password: null,
- user: null,
- });
- return next();
- }
- /* eslint-disable newline-per-chained-call */
- tmpUsername = `temp_${Math.random().toString(36).slice(-16)}`;
- password = Math.random().toString(36).slice(-16);
- /* eslint-enable newline-per-chained-call */
- newUser.username = tmpUsername;
- newUser.email = email;
- newUser.setPassword(password);
- newUser.createdAt = Date.now();
- newUser.status = STATUS_INVITED;
- const globalLang = configManager.getConfig('crowi', 'app:globalLang');
- if (globalLang != null) {
- newUser.lang = globalLang;
- }
- newUser.save((err, userData) => {
- if (err) {
- createdUserList.push({
- email,
- password: null,
- user: null,
- });
- debug('save failed!! ', err);
- }
- else {
- createdUserList.push({
- email,
- password,
- user: userData,
- });
- debug('saved!', email);
- }
- next();
- });
- });
- },
- (err) => {
- if (err) {
- debug('error occured while iterate email list');
- }
- if (toSendEmail) {
- // TODO: メール送信部分のロジックをサービス化する
- async.each(
- createdUserList,
- (user, next) => {
- if (user.password === null) {
- return next();
- }
- const appTitle = crowi.appService.getAppTitle();
- mailer.send({
- to: user.email,
- subject: `Invitation to ${appTitle}`,
- template: path.join(crowi.localeDir, 'en-US/admin/userInvitation.txt'),
- vars: {
- email: user.email,
- password: user.password,
- url: crowi.appService.getSiteUrl(),
- appTitle,
- },
- },
- (err, s) => {
- debug('completed to send email: ', err, s);
- next();
- });
- },
- (err) => {
- debug('Sending invitation email completed.', err);
- },
- );
- }
- debug('createdUserList!!! ', createdUserList);
- return callback(null, createdUserList);
- },
- );
- };
- userSchema.statics.createUserByEmailAndPasswordAndStatus = async function(name, username, email, password, lang, status, callback) {
- const User = this;
- const newUser = new User();
- // check user upper limit
- const isUserCountExceedsUpperLimit = await User.isUserCountExceedsUpperLimit();
- if (isUserCountExceedsUpperLimit) {
- const err = new UserUpperLimitException();
- return callback(err);
- }
- // check email duplication because email must be unique
- const count = await this.count({ email });
- if (count > 0) {
- // eslint-disable-next-line no-param-reassign
- email = generateRandomEmail();
- }
- newUser.name = name;
- newUser.username = username;
- newUser.email = email;
- if (password != null) {
- newUser.setPassword(password);
- }
- const configManager = crowi.configManager;
- const globalLang = configManager.getConfig('crowi', 'app:globalLang');
- if (globalLang != null) {
- newUser.lang = globalLang;
- }
- if (lang != null) {
- newUser.lang = lang;
- }
- newUser.createdAt = Date.now();
- newUser.status = status || decideUserStatusOnRegistration();
- newUser.save((err, userData) => {
- if (err) {
- logger.error('createUserByEmailAndPasswordAndStatus failed: ', err);
- return callback(err);
- }
- if (userData.status === STATUS_ACTIVE) {
- userEvent.emit('activated', userData);
- }
- return callback(err, userData);
- });
- };
- /**
- * A wrapper function of createUserByEmailAndPasswordAndStatus with callback
- *
- */
- userSchema.statics.createUserByEmailAndPassword = function(name, username, email, password, lang, callback) {
- this.createUserByEmailAndPasswordAndStatus(name, username, email, password, lang, undefined, callback);
- };
- /**
- * A wrapper function of createUserByEmailAndPasswordAndStatus
- *
- * @return {Promise<User>}
- */
- userSchema.statics.createUser = function(name, username, email, password, lang, status) {
- const User = this;
- return new Promise((resolve, reject) => {
- User.createUserByEmailAndPasswordAndStatus(name, username, email, password, lang, status, (err, userData) => {
- if (err) {
- return reject(err);
- }
- return resolve(userData);
- });
- });
- };
- userSchema.statics.getUsernameByPath = function(path) {
- let username = null;
- const match = path.match(/^\/user\/([^/]+)\/?/);
- if (match) {
- username = match[1];
- }
- return username;
- };
- class UserUpperLimitException {
- constructor() {
- this.name = this.constructor.name;
- }
- }
- userSchema.statics.STATUS_REGISTERED = STATUS_REGISTERED;
- userSchema.statics.STATUS_ACTIVE = STATUS_ACTIVE;
- userSchema.statics.STATUS_SUSPENDED = STATUS_SUSPENDED;
- userSchema.statics.STATUS_DELETED = STATUS_DELETED;
- userSchema.statics.STATUS_INVITED = STATUS_INVITED;
- userSchema.statics.USER_PUBLIC_FIELDS = USER_PUBLIC_FIELDS;
- userSchema.statics.IMAGE_POPULATION = IMAGE_POPULATION;
- userSchema.statics.PAGE_ITEMS = PAGE_ITEMS;
- userSchema.statics.LANG_EN = LANG_EN;
- userSchema.statics.LANG_EN_US = LANG_EN_US;
- userSchema.statics.LANG_EN_GB = LANG_EN_US;
- userSchema.statics.LANG_JA = LANG_JA;
- return mongoose.model('User', userSchema);
- };
|