|
@@ -7,6 +7,8 @@ import { i18n } from '^/config/next-i18next.config';
|
|
|
import { generateGravatarSrc } from '~/utils/gravatar';
|
|
import { generateGravatarSrc } from '~/utils/gravatar';
|
|
|
import loggerFactory from '~/utils/logger';
|
|
import loggerFactory from '~/utils/logger';
|
|
|
|
|
|
|
|
|
|
+import { aclService } from '../service/acl';
|
|
|
|
|
+import { configManager } from '../service/config-manager';
|
|
|
import { getModelSafely } from '../util/mongoose-utils';
|
|
import { getModelSafely } from '../util/mongoose-utils';
|
|
|
|
|
|
|
|
import { Attachment } from './attachment';
|
|
import { Attachment } from './attachment';
|
|
@@ -99,8 +101,6 @@ const factory = (crowi) => {
|
|
|
function decideUserStatusOnRegistration() {
|
|
function decideUserStatusOnRegistration() {
|
|
|
validateCrowi();
|
|
validateCrowi();
|
|
|
|
|
|
|
|
- const { configManager, aclService } = crowi;
|
|
|
|
|
-
|
|
|
|
|
const isInstalled = configManager.getConfig('crowi', 'app:installed');
|
|
const isInstalled = configManager.getConfig('crowi', 'app:installed');
|
|
|
if (!isInstalled) {
|
|
if (!isInstalled) {
|
|
|
return STATUS_ACTIVE; // is this ok?
|
|
return STATUS_ACTIVE; // is this ok?
|
|
@@ -278,7 +278,7 @@ const factory = (crowi) => {
|
|
|
this.name = name;
|
|
this.name = name;
|
|
|
this.username = username;
|
|
this.username = username;
|
|
|
this.status = STATUS_ACTIVE;
|
|
this.status = STATUS_ACTIVE;
|
|
|
- this.isEmailPublished = crowi.configManager.getConfig('crowi', 'customize:isEmailPublishedForNewUser');
|
|
|
|
|
|
|
+ this.isEmailPublished = configManager.getConfig('crowi', 'customize:isEmailPublishedForNewUser');
|
|
|
|
|
|
|
|
this.save((err, userData) => {
|
|
this.save((err, userData) => {
|
|
|
userEvent.emit('activated', userData);
|
|
userEvent.emit('activated', userData);
|
|
@@ -371,7 +371,7 @@ const factory = (crowi) => {
|
|
|
userSchema.statics.isEmailValid = function(email, callback) {
|
|
userSchema.statics.isEmailValid = function(email, callback) {
|
|
|
validateCrowi();
|
|
validateCrowi();
|
|
|
|
|
|
|
|
- const whitelist = crowi.configManager.getConfig('crowi', 'security:registrationWhitelist');
|
|
|
|
|
|
|
+ const whitelist = configManager.getConfig('crowi', 'security:registrationWhitelist');
|
|
|
|
|
|
|
|
if (Array.isArray(whitelist) && whitelist.length > 0) {
|
|
if (Array.isArray(whitelist) && whitelist.length > 0) {
|
|
|
return whitelist.some((allowedEmail) => {
|
|
return whitelist.some((allowedEmail) => {
|
|
@@ -449,7 +449,7 @@ const factory = (crowi) => {
|
|
|
if (apiToken == null) {
|
|
if (apiToken == null) {
|
|
|
return Promise.resolve(null);
|
|
return Promise.resolve(null);
|
|
|
}
|
|
}
|
|
|
- return this.findOne({ apiToken });
|
|
|
|
|
|
|
+ return this.findOne({ apiToken }).lean();
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
userSchema.statics.findUserByGoogleId = function(googleId, callback) {
|
|
userSchema.statics.findUserByGoogleId = function(googleId, callback) {
|
|
@@ -480,8 +480,6 @@ const factory = (crowi) => {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
userSchema.statics.isUserCountExceedsUpperLimit = async function() {
|
|
userSchema.statics.isUserCountExceedsUpperLimit = async function() {
|
|
|
- const { configManager } = crowi;
|
|
|
|
|
-
|
|
|
|
|
const userUpperLimit = configManager.getConfig('crowi', 'security:userUpperLimit');
|
|
const userUpperLimit = configManager.getConfig('crowi', 'security:userUpperLimit');
|
|
|
|
|
|
|
|
const activeUsers = await this.countActiveUsers();
|
|
const activeUsers = await this.countActiveUsers();
|
|
@@ -565,8 +563,6 @@ const factory = (crowi) => {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
userSchema.statics.createUserByEmail = async function(email) {
|
|
userSchema.statics.createUserByEmail = async function(email) {
|
|
|
- const configManager = crowi.configManager;
|
|
|
|
|
-
|
|
|
|
|
const User = this;
|
|
const User = this;
|
|
|
const newUser = new User();
|
|
const newUser = new User();
|
|
|
|
|
|
|
@@ -654,8 +650,6 @@ const factory = (crowi) => {
|
|
|
newUser.setPassword(password);
|
|
newUser.setPassword(password);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const configManager = crowi.configManager;
|
|
|
|
|
-
|
|
|
|
|
// Default email show/hide is up to the administrator
|
|
// Default email show/hide is up to the administrator
|
|
|
newUser.isEmailPublished = configManager.getConfig('crowi', 'customize:isEmailPublishedForNewUser');
|
|
newUser.isEmailPublished = configManager.getConfig('crowi', 'customize:isEmailPublishedForNewUser');
|
|
|
|
|
|