mirror of
https://github.com/kokonect-link/cherrypick
synced 2024-11-01 15:45:58 +09:00
Fix #6203
This commit is contained in:
parent
cc66a1f9c7
commit
6a732ab1cd
@ -22,8 +22,6 @@ export async function signup(username: User['username'], password: UserProfile['
|
|||||||
throw new Error('INVALID_PASSWORD');
|
throw new Error('INVALID_PASSWORD');
|
||||||
}
|
}
|
||||||
|
|
||||||
const usersCount = await Users.count({});
|
|
||||||
|
|
||||||
// Generate hash of password
|
// Generate hash of password
|
||||||
const salt = await bcrypt.genSalt(8);
|
const salt = await bcrypt.genSalt(8);
|
||||||
const hash = await bcrypt.hash(password, salt);
|
const hash = await bcrypt.hash(password, salt);
|
||||||
@ -76,7 +74,9 @@ export async function signup(username: User['username'], password: UserProfile['
|
|||||||
usernameLower: username.toLowerCase(),
|
usernameLower: username.toLowerCase(),
|
||||||
host: toPunyNullable(host),
|
host: toPunyNullable(host),
|
||||||
token: secret,
|
token: secret,
|
||||||
isAdmin: usersCount === 0,
|
isAdmin: (await Users.count({
|
||||||
|
host: null,
|
||||||
|
})) === 0,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
await transactionalEntityManager.save(new UserKeypair({
|
await transactionalEntityManager.save(new UserKeypair({
|
||||||
|
@ -17,7 +17,9 @@ export const meta = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default define(meta, async (ps, me) => {
|
export default define(meta, async (ps, me) => {
|
||||||
const noUsers = (await Users.count({})) === 0;
|
const noUsers = (await Users.count({
|
||||||
|
host: null,
|
||||||
|
})) === 0;
|
||||||
if (!noUsers && me == null) throw new Error('access denied');
|
if (!noUsers && me == null) throw new Error('access denied');
|
||||||
|
|
||||||
const { account, secret } = await signup(ps.username, ps.password);
|
const { account, secret } = await signup(ps.username, ps.password);
|
||||||
|
@ -137,7 +137,9 @@ export default define(meta, async (ps, me) => {
|
|||||||
category: e.category,
|
category: e.category,
|
||||||
url: e.url,
|
url: e.url,
|
||||||
})),
|
})),
|
||||||
requireSetup: (await Users.count({})) === 0,
|
requireSetup: (await Users.count({
|
||||||
|
host: null,
|
||||||
|
})) === 0,
|
||||||
enableEmail: instance.enableEmail,
|
enableEmail: instance.enableEmail,
|
||||||
|
|
||||||
enableTwitterIntegration: instance.enableTwitterIntegration,
|
enableTwitterIntegration: instance.enableTwitterIntegration,
|
||||||
|
Loading…
Reference in New Issue
Block a user