Make registrations configurable by env
This commit is contained in:
parent
0adb6f5eba
commit
82c4f0827e
|
@ -126,6 +126,10 @@ const Conf = {
|
||||||
'system',
|
'system',
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
/** Whether registrations are open or closed. */
|
||||||
|
get registrations() {
|
||||||
|
return optionalBooleanSchema.parse(Deno.env.get('DITTO_REGISTRATIONS')) ?? false;
|
||||||
|
},
|
||||||
/** Proof-of-work configuration. */
|
/** Proof-of-work configuration. */
|
||||||
pow: {
|
pow: {
|
||||||
get registrations() {
|
get registrations() {
|
||||||
|
|
|
@ -22,6 +22,10 @@ const createAccountSchema = z.object({
|
||||||
});
|
});
|
||||||
|
|
||||||
const createAccountController: AppController = async (c) => {
|
const createAccountController: AppController = async (c) => {
|
||||||
|
if (!Conf.registrations) {
|
||||||
|
return c.json({ error: 'Registrations are disabled.' }, 403);
|
||||||
|
}
|
||||||
|
|
||||||
const pubkey = c.get('pubkey')!;
|
const pubkey = c.get('pubkey')!;
|
||||||
const result = createAccountSchema.safeParse(await c.req.json());
|
const result = createAccountSchema.safeParse(await c.req.json());
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ const instanceController: AppController = (c) => {
|
||||||
title: 'Ditto',
|
title: 'Ditto',
|
||||||
description: 'An efficient and flexible social media server.',
|
description: 'An efficient and flexible social media server.',
|
||||||
short_description: 'An efficient and flexible social media server.',
|
short_description: 'An efficient and flexible social media server.',
|
||||||
registrations: false,
|
registrations: Conf.registrations,
|
||||||
max_toot_chars: Conf.postCharLimit,
|
max_toot_chars: Conf.postCharLimit,
|
||||||
configuration: {
|
configuration: {
|
||||||
media_attachments: {
|
media_attachments: {
|
||||||
|
|
Loading…
Reference in New Issue