diff options
| author | Mar0xy <marie@kaifa.ch> | 2023-10-18 02:41:36 +0200 |
|---|---|---|
| committer | Mar0xy <marie@kaifa.ch> | 2023-10-18 02:41:36 +0200 |
| commit | 2f2d88dcfc76bac6815d60fa9915b8e797853292 (patch) | |
| tree | fa3e903e9444ee4b92d91a6ff58264a4387d7523 /packages/backend/src/core/SignupService.ts | |
| parent | chore: change some misskey references to sharkey (diff) | |
| download | sharkey-2f2d88dcfc76bac6815d60fa9915b8e797853292.tar.gz sharkey-2f2d88dcfc76bac6815d60fa9915b8e797853292.tar.bz2 sharkey-2f2d88dcfc76bac6815d60fa9915b8e797853292.zip | |
add: Require Approval for Signup
Diffstat (limited to 'packages/backend/src/core/SignupService.ts')
| -rw-r--r-- | packages/backend/src/core/SignupService.ts | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/packages/backend/src/core/SignupService.ts b/packages/backend/src/core/SignupService.ts index 359957cd52..32e3dee937 100644 --- a/packages/backend/src/core/SignupService.ts +++ b/packages/backend/src/core/SignupService.ts @@ -48,10 +48,12 @@ export class SignupService { password?: string | null; passwordHash?: MiUserProfile['password'] | null; host?: string | null; + reason?: string | null; ignorePreservedUsernames?: boolean; }) { - const { username, password, passwordHash, host } = opts; + const { username, password, passwordHash, host, reason } = opts; let hash = passwordHash; + const instance = await this.metaService.fetch(true); // Validate username if (!this.userEntityService.validateLocalUsername(username)) { @@ -85,7 +87,6 @@ export class SignupService { const isTheFirstUser = (await this.usersRepository.countBy({ host: IsNull() })) === 0; if (!opts.ignorePreservedUsernames && !isTheFirstUser) { - const instance = await this.metaService.fetch(true); const isPreserved = instance.preservedUsernames.map(x => x.toLowerCase()).includes(username.toLowerCase()); if (isPreserved) { throw new Error('USED_USERNAME'); @@ -110,6 +111,9 @@ export class SignupService { )); let account!: MiUser; + let defaultApproval = false; + + if (!instance.approvalRequiredForSignup) defaultApproval = true; // Start transaction await this.db.transaction(async transactionalEntityManager => { @@ -127,6 +131,8 @@ export class SignupService { host: this.utilityService.toPunyNullable(host), token: secret, isRoot: isTheFirstUser, + approved: defaultApproval, + signupReason: reason, })); await transactionalEntityManager.save(new MiUserKeypair({ |