mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-20 15:30:39 +01:00
* feat: #7514 Optional timer for registration queue * feat: show minutes in average time * fix: don't show total number of minutes * feat: implement requested changes * fix: just store minutes instead of milliseconds * feat: set default values
This commit is contained in:
@@ -136,6 +136,8 @@
|
|||||||
"necroThreshold": 7,
|
"necroThreshold": 7,
|
||||||
"categoryWatchState": "watching",
|
"categoryWatchState": "watching",
|
||||||
"submitPluginUsage": 1,
|
"submitPluginUsage": 1,
|
||||||
|
"showAverageApprovalTime": true,
|
||||||
|
"autoApproveTime": 0,
|
||||||
"maxUserSessions": 10,
|
"maxUserSessions": 10,
|
||||||
"useCompression": 0
|
"useCompression": 0
|
||||||
}
|
}
|
||||||
@@ -43,6 +43,9 @@
|
|||||||
"registration-type.disabled": "No registration",
|
"registration-type.disabled": "No registration",
|
||||||
"registration-type.help": "Normal - Users can register from the /register page.<br/>\nInvite Only - Users can invite others from the <a href=\"%1/users\" target=\"_blank\">users</a> page.<br/>\nAdmin Invite Only - Only administrators can invite others from <a href=\"%1/users\" target=\"_blank\">users</a> and <a href=\"%1/admin/manage/users\">admin/manage/users</a> pages.<br/>\nNo registration - No user registration.<br/>",
|
"registration-type.help": "Normal - Users can register from the /register page.<br/>\nInvite Only - Users can invite others from the <a href=\"%1/users\" target=\"_blank\">users</a> page.<br/>\nAdmin Invite Only - Only administrators can invite others from <a href=\"%1/users\" target=\"_blank\">users</a> and <a href=\"%1/admin/manage/users\">admin/manage/users</a> pages.<br/>\nNo registration - No user registration.<br/>",
|
||||||
"registration-approval-type.help": "Normal - Users are registered immediately.<br/>\nAdmin Approval - User registrations are placed in an <a href=\"%1/admin/manage/registration\">approval queue</a> for administrators.<br/>\nAdmin Approval for IPs - Normal for new users, Admin Approval for IP addresses that already have an account.<br/>",
|
"registration-approval-type.help": "Normal - Users are registered immediately.<br/>\nAdmin Approval - User registrations are placed in an <a href=\"%1/admin/manage/registration\">approval queue</a> for administrators.<br/>\nAdmin Approval for IPs - Normal for new users, Admin Approval for IP addresses that already have an account.<br/>",
|
||||||
|
"registration-queue-auto-approve-time": "Automatic Approval Time",
|
||||||
|
"registration-queue-auto-approve-time-help": "Hours before user is approved automatically. 0 to disable.",
|
||||||
|
"registration-queue-show-average-time": "Show users average time it takes to approve a new user",
|
||||||
"registration.max-invites": "Maximum Invitations per User",
|
"registration.max-invites": "Maximum Invitations per User",
|
||||||
"max-invites": "Maximum Invitations per User",
|
"max-invites": "Maximum Invitations per User",
|
||||||
"max-invites-help": "0 for no restriction. Admins get infinite invitations<br>Only applicable for \"Invite Only\"",
|
"max-invites-help": "0 for no restriction. Admins get infinite invitations<br>Only applicable for \"Invite Only\"",
|
||||||
|
|||||||
@@ -1,27 +1,28 @@
|
|||||||
{
|
{
|
||||||
"register": "Register",
|
"register": "Register",
|
||||||
"cancel_registration": "Cancel Registration",
|
"cancel_registration": "Cancel Registration",
|
||||||
"help.email": "By default, your email will be hidden from the public.",
|
"help.email": "By default, your email will be hidden from the public.",
|
||||||
"help.username_restrictions": "A unique username between %1 and %2 characters. Others can mention you with @<span id='yourUsername'>username</span>.",
|
"help.username_restrictions": "A unique username between %1 and %2 characters. Others can mention you with @<span id='yourUsername'>username</span>.",
|
||||||
"help.minimum_password_length": "Your password's length must be at least %1 characters.",
|
"help.minimum_password_length": "Your password's length must be at least %1 characters.",
|
||||||
"email_address": "Email Address",
|
"email_address": "Email Address",
|
||||||
"email_address_placeholder": "Enter Email Address",
|
"email_address_placeholder": "Enter Email Address",
|
||||||
"username": "Username",
|
"username": "Username",
|
||||||
"username_placeholder": "Enter Username",
|
"username_placeholder": "Enter Username",
|
||||||
"password": "Password",
|
"password": "Password",
|
||||||
"password_placeholder": "Enter Password",
|
"password_placeholder": "Enter Password",
|
||||||
"confirm_password": "Confirm Password",
|
"confirm_password": "Confirm Password",
|
||||||
"confirm_password_placeholder": "Confirm Password",
|
"confirm_password_placeholder": "Confirm Password",
|
||||||
"register_now_button": "Register Now",
|
"register_now_button": "Register Now",
|
||||||
"alternative_registration": "Alternative Registration",
|
"alternative_registration": "Alternative Registration",
|
||||||
"terms_of_use": "Terms of Use",
|
"terms_of_use": "Terms of Use",
|
||||||
"agree_to_terms_of_use": "I agree to the Terms of Use",
|
"agree_to_terms_of_use": "I agree to the Terms of Use",
|
||||||
"terms_of_use_error": "You must agree to the Terms of Use",
|
"terms_of_use_error": "You must agree to the Terms of Use",
|
||||||
"registration-added-to-queue": "Your registration has been added to the approval queue. You will receive an email when it is accepted by an administrator.",
|
"registration-added-to-queue": "Your registration has been added to the approval queue. You will receive an email when it is accepted by an administrator.",
|
||||||
"interstitial.intro": "We require some additional information before we can create your account.",
|
"registration-queue-average-time": "Our average time for approving memberships is %1 hours %2 minutes.",
|
||||||
"interstitial.errors-found": "We could not complete your registration:",
|
"registration-queue-auto-approve-time": "Your membership to this forum will be fully activated in up to %1 hours.",
|
||||||
|
"interstitial.intro": "We require some additional information before we can create your account.",
|
||||||
"gdpr_agree_data": "I consent to the collection and processing of my personal information on this website.",
|
"interstitial.errors-found": "We could not complete your registration:",
|
||||||
"gdpr_agree_email": "I consent to receive digest and notification emails from this website.",
|
"gdpr_agree_data": "I consent to the collection and processing of my personal information on this website.",
|
||||||
"gdpr_consent_denied": "You must give consent to this site to collect/process your information, and to send you emails."
|
"gdpr_agree_email": "I consent to receive digest and notification emails from this website.",
|
||||||
}
|
"gdpr_consent_denied": "You must give consent to this site to collect/process your information, and to send you emails."
|
||||||
|
}
|
||||||
|
|||||||
@@ -118,7 +118,15 @@ authenticationController.register = async function (req, res) {
|
|||||||
async function addToApprovalQueue(req, userData) {
|
async function addToApprovalQueue(req, userData) {
|
||||||
userData.ip = req.ip;
|
userData.ip = req.ip;
|
||||||
await user.addToApprovalQueue(userData);
|
await user.addToApprovalQueue(userData);
|
||||||
return { message: '[[register:registration-added-to-queue]]' };
|
let message = '[[register:registration-added-to-queue]]';
|
||||||
|
if (meta.config.showAverageApprovalTime) {
|
||||||
|
const average_time = await db.getObjectField('registration:queue:approval:times', 'average');
|
||||||
|
message += ` [[register:registration-queue-average-time, ${Math.floor(average_time / 60)}, ${average_time % 60}]]`;
|
||||||
|
}
|
||||||
|
if (meta.config.autoApproveTime > 0) {
|
||||||
|
message += ` [[register:registration-queue-auto-approve-time, ${meta.config.autoApproveTime}]]`;
|
||||||
|
}
|
||||||
|
return { message: message };
|
||||||
}
|
}
|
||||||
|
|
||||||
authenticationController.registerComplete = function (req, res, next) {
|
authenticationController.registerComplete = function (req, res, next) {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const validator = require('validator');
|
const validator = require('validator');
|
||||||
|
const cronJob = require('cron').CronJob;
|
||||||
|
|
||||||
const db = require('../database');
|
const db = require('../database');
|
||||||
const meta = require('../meta');
|
const meta = require('../meta');
|
||||||
@@ -12,6 +13,10 @@ const slugify = require('../slugify');
|
|||||||
const plugins = require('../plugins');
|
const plugins = require('../plugins');
|
||||||
|
|
||||||
module.exports = function (User) {
|
module.exports = function (User) {
|
||||||
|
new cronJob('0 * * * * *', function () {
|
||||||
|
User.autoApprove();
|
||||||
|
}, null, true);
|
||||||
|
|
||||||
User.addToApprovalQueue = async function (userData) {
|
User.addToApprovalQueue = async function (userData) {
|
||||||
userData.username = userData.username.trim();
|
userData.username = userData.username.trim();
|
||||||
userData.userslug = slugify(userData.username);
|
userData.userslug = slugify(userData.username);
|
||||||
@@ -59,7 +64,7 @@ module.exports = function (User) {
|
|||||||
if (!userData) {
|
if (!userData) {
|
||||||
throw new Error('[[error:invalid-data]]');
|
throw new Error('[[error:invalid-data]]');
|
||||||
}
|
}
|
||||||
|
const creation_time = await db.sortedSetScore('registration:queue', username);
|
||||||
const uid = await User.create(userData);
|
const uid = await User.create(userData);
|
||||||
await User.setUserField(uid, 'password', userData.hashedPassword);
|
await User.setUserField(uid, 'password', userData.hashedPassword);
|
||||||
await removeFromQueue(username);
|
await removeFromQueue(username);
|
||||||
@@ -71,6 +76,9 @@ module.exports = function (User) {
|
|||||||
template: 'registration_accepted',
|
template: 'registration_accepted',
|
||||||
uid: uid,
|
uid: uid,
|
||||||
});
|
});
|
||||||
|
const total = await db.incrObjectField('registration:queue:approval:times', 'totalTime', Math.floor((Date.now() - creation_time) / 60000));
|
||||||
|
const counter = await db.incrObjectField('registration:queue:approval:times', 'counter', 1);
|
||||||
|
await db.setObjectField('registration:queue:approval:times', 'average', total / counter);
|
||||||
return uid;
|
return uid;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -140,4 +148,16 @@ module.exports = function (User) {
|
|||||||
const uids = await User.getUidsFromSet('ip:' + user.ip + ':uid', 0, -1);
|
const uids = await User.getUidsFromSet('ip:' + user.ip + ':uid', 0, -1);
|
||||||
user.ipMatch = await User.getUsersFields(uids, ['uid', 'username', 'picture']);
|
user.ipMatch = await User.getUsersFields(uids, ['uid', 'username', 'picture']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
User.autoApprove = async function () {
|
||||||
|
if (meta.config.autoApproveTime <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const users = await db.getSortedSetRevRangeWithScores('registration:queue', 0, -1);
|
||||||
|
const now = Date.now();
|
||||||
|
for (const user of users.filter(user => now - user.score >= meta.config.autoApproveTime * 3600000)) {
|
||||||
|
// eslint-disable-next-line no-await-in-loop
|
||||||
|
await User.acceptRegistration(user.value);
|
||||||
|
}
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -186,6 +186,19 @@
|
|||||||
[[admin/settings/user:registration-approval-type.help, {config.relative_path}]]
|
[[admin/settings/user:registration-approval-type.help, {config.relative_path}]]
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>[[admin/settings/user:registration-queue-auto-approve-time]]</label>
|
||||||
|
<input type="number" class="form-control" data-field="autoApproveTime" placeholder="0">
|
||||||
|
<p class="help-block">
|
||||||
|
[[admin/settings/user:registration-queue-auto-approve-time-help]]
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="checkbox">
|
||||||
|
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
|
||||||
|
<input class="mdl-switch__input" type="checkbox" data-field="showAverageApprovalTime">
|
||||||
|
<span class="mdl-switch__label"><strong>[[admin/settings/user:registration-queue-show-average-time]]</strong></span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>[[admin/settings/user:max-invites]]</label>
|
<label>[[admin/settings/user:max-invites]]</label>
|
||||||
<input type="number" class="form-control" data-field="maximumInvites" placeholder="0">
|
<input type="number" class="form-control" data-field="maximumInvites" placeholder="0">
|
||||||
|
|||||||
Reference in New Issue
Block a user