mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-04-14 11:46:23 +00:00
Configurable registration only by invite.
This commit is contained in:
parent
c5e5e3bb71
commit
1d843af3cd
2 changed files with 10 additions and 1 deletions
|
|
@ -28,6 +28,7 @@
|
|||
"GOOGLE_CLIENT_SECRET": "aaaabbbbccccddddeeeeffff00001111",
|
||||
"IAP_GOOGLE_KEYDIR": "/path/to/google/public/key/dir/",
|
||||
"IGNORE_REDIRECT": "true",
|
||||
"INVITE_ONLY": "true",
|
||||
"ITUNES_SHARED_SECRET": "aaaabbbbccccddddeeeeffff00001111",
|
||||
"LOGGLY_CLIENT_TOKEN": "token",
|
||||
"LOGGLY_SUBDOMAIN": "example-subdomain",
|
||||
|
|
|
|||
|
|
@ -18,7 +18,9 @@ import {
|
|||
} from './social';
|
||||
import { loginRes } from './utils';
|
||||
import { verifyUsername } from '../user/validation';
|
||||
import nconf from 'nconf';
|
||||
|
||||
const INVITE_ONLY = nconf.get('INVITE_ONLY') === 'true';
|
||||
const USERNAME_LENGTH_MIN = 1;
|
||||
const USERNAME_LENGTH_MAX = 20;
|
||||
|
||||
|
|
@ -60,7 +62,9 @@ async function _handleGroupInvitation (user, invite) {
|
|||
}
|
||||
} catch (err) {
|
||||
logger.error(err);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function hasLocalAuth (user) {
|
||||
|
|
@ -191,7 +195,11 @@ async function registerLocal (req, res, { isV3 = false }) {
|
|||
|
||||
// we check for partyInvite for backward compatibility
|
||||
if (req.query.groupInvite || req.query.partyInvite) {
|
||||
await _handleGroupInvitation(newUser, req.query.groupInvite || req.query.partyInvite);
|
||||
const success = await _handleGroupInvitation(newUser, req.query.groupInvite || req.query.partyInvite);
|
||||
if (INVITE_ONLY && !success)
|
||||
throw new NotAuthorized(res.t('inviteOnly'));
|
||||
} else if (INVITE_ONLY) {
|
||||
throw new NotAuthorized(res.t('inviteOnly'));
|
||||
}
|
||||
|
||||
const savedUser = await newUser.save();
|
||||
|
|
|
|||
Loading…
Reference in a new issue