mirror of
https://codeberg.org/yeentown/barkey
synced 2024-11-22 17:15:13 +00:00
refactor
This commit is contained in:
parent
b3ec47c3f4
commit
f3e43a0fc6
2 changed files with 5 additions and 6 deletions
|
@ -80,7 +80,9 @@ export class SignupService {
|
||||||
throw new Error('USED_USERNAME');
|
throw new Error('USED_USERNAME');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!opts.ignorePreservedUsernames) {
|
const isTheFirstUser = (await this.usersRepository.countBy({ host: IsNull() })) === 0;
|
||||||
|
|
||||||
|
if (!opts.ignorePreservedUsernames || !isTheFirstUser) {
|
||||||
const instance = await this.metaService.fetch(true);
|
const instance = await this.metaService.fetch(true);
|
||||||
const isPreserved = instance.preservedUsernames.map(x => x.toLowerCase()).includes(username.toLowerCase());
|
const isPreserved = instance.preservedUsernames.map(x => x.toLowerCase()).includes(username.toLowerCase());
|
||||||
if (isPreserved) {
|
if (isPreserved) {
|
||||||
|
@ -123,9 +125,7 @@ export class SignupService {
|
||||||
usernameLower: username.toLowerCase(),
|
usernameLower: username.toLowerCase(),
|
||||||
host: this.utilityService.toPunyNullable(host),
|
host: this.utilityService.toPunyNullable(host),
|
||||||
token: secret,
|
token: secret,
|
||||||
isRoot: (await this.usersRepository.countBy({
|
isRoot: isTheFirstUser,
|
||||||
host: IsNull(),
|
|
||||||
})) === 0,
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
await transactionalEntityManager.save(new UserKeypair({
|
await transactionalEntityManager.save(new UserKeypair({
|
||||||
|
|
|
@ -169,7 +169,6 @@ export class SignupApiService {
|
||||||
try {
|
try {
|
||||||
const { account, secret } = await this.signupService.signup({
|
const { account, secret } = await this.signupService.signup({
|
||||||
username, password, host,
|
username, password, host,
|
||||||
ignorePreservedUsernames: (await this.usersRepository.countBy({ host: IsNull() })) === 0,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const res = await this.userEntityService.pack(account, account, {
|
const res = await this.userEntityService.pack(account, account, {
|
||||||
|
|
Loading…
Reference in a new issue