|
@@ -11,6 +11,8 @@ const md5 = require('md5');
|
|
|
const ObjectId = mongoose.Schema.Types.ObjectId;
|
|
const ObjectId = mongoose.Schema.Types.ObjectId;
|
|
|
const crypto = require('crypto');
|
|
const crypto = require('crypto');
|
|
|
|
|
|
|
|
|
|
+const { listLocaleIds, listLocaleAliases } = require('@commons/util/locale-utils');
|
|
|
|
|
+
|
|
|
module.exports = function(crowi) {
|
|
module.exports = function(crowi) {
|
|
|
const STATUS_REGISTERED = 1;
|
|
const STATUS_REGISTERED = 1;
|
|
|
const STATUS_ACTIVE = 2;
|
|
const STATUS_ACTIVE = 2;
|
|
@@ -22,11 +24,6 @@ module.exports = function(crowi) {
|
|
|
/* eslint-disable no-unused-vars */
|
|
/* eslint-disable no-unused-vars */
|
|
|
const IMAGE_POPULATION = { path: 'imageAttachment', select: 'filePathProxied' };
|
|
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_JP';
|
|
|
|
|
-
|
|
|
|
|
const PAGE_ITEMS = 50;
|
|
const PAGE_ITEMS = 50;
|
|
|
|
|
|
|
|
let userEvent;
|
|
let userEvent;
|
|
@@ -58,8 +55,8 @@ module.exports = function(crowi) {
|
|
|
apiToken: { type: String, index: true },
|
|
apiToken: { type: String, index: true },
|
|
|
lang: {
|
|
lang: {
|
|
|
type: String,
|
|
type: String,
|
|
|
- enum: crowi.locales,
|
|
|
|
|
- default: LANG_EN_US,
|
|
|
|
|
|
|
+ enum: listLocaleIds().concat(listLocaleAliases()),
|
|
|
|
|
+ default: 'en_US',
|
|
|
},
|
|
},
|
|
|
status: {
|
|
status: {
|
|
|
type: Number, required: true, default: STATUS_ACTIVE, index: true,
|
|
type: Number, required: true, default: STATUS_ACTIVE, index: true,
|
|
@@ -146,16 +143,6 @@ module.exports = function(crowi) {
|
|
|
return hasher.digest('base64');
|
|
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.isPasswordSet = function() {
|
|
userSchema.methods.isPasswordSet = function() {
|
|
|
if (this.password) {
|
|
if (this.password) {
|
|
|
return true;
|
|
return true;
|
|
@@ -354,7 +341,6 @@ module.exports = function(crowi) {
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- userSchema.statics.getLanguageLabels = getLanguageLabels;
|
|
|
|
|
userSchema.statics.getUserStatusLabels = function() {
|
|
userSchema.statics.getUserStatusLabels = function() {
|
|
|
const userStatus = {};
|
|
const userStatus = {};
|
|
|
userStatus[STATUS_REGISTERED] = 'Approval Pending';
|
|
userStatus[STATUS_REGISTERED] = 'Approval Pending';
|
|
@@ -767,10 +753,5 @@ module.exports = function(crowi) {
|
|
|
userSchema.statics.IMAGE_POPULATION = IMAGE_POPULATION;
|
|
userSchema.statics.IMAGE_POPULATION = IMAGE_POPULATION;
|
|
|
userSchema.statics.PAGE_ITEMS = PAGE_ITEMS;
|
|
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);
|
|
return mongoose.model('User', userSchema);
|
|
|
};
|
|
};
|