refactor: migrate to typeorm 3.0 (#8443)

* wip

* wip

* wip

* Update following.ts

* wip

* wip

* wip

* Update resolve-user.ts

* maxQueryExecutionTime

* wip

* wip
This commit is contained in:
syuilo
2022-03-26 15:34:00 +09:00
committed by GitHub
parent 41c87074e6
commit 1c67c26bd8
325 changed files with 1314 additions and 1494 deletions

View File

@@ -8,6 +8,7 @@ import { ILocalUser } from '@/models/entities/user.js';
import { genId } from '@/misc/gen-id.js';
import { verifyLogin, hash } from '../2fa.js';
import { randomBytes } from 'node:crypto';
import { IsNull } from 'typeorm';
export default async (ctx: Koa.Context) => {
ctx.set('Access-Control-Allow-Origin', config.url);
@@ -39,9 +40,9 @@ export default async (ctx: Koa.Context) => {
}
// Fetch user
const user = await Users.findOne({
const user = await Users.findOneBy({
usernameLower: username.toLowerCase(),
host: null,
host: IsNull(),
}) as ILocalUser;
if (user == null) {
@@ -58,7 +59,7 @@ export default async (ctx: Koa.Context) => {
return;
}
const profile = await UserProfiles.findOneOrFail(user.id);
const profile = await UserProfiles.findOneByOrFail({ userId: user.id });
// Compare password
const same = await bcrypt.compare(password, profile.password!);
@@ -123,7 +124,7 @@ export default async (ctx: Koa.Context) => {
const clientDataJSON = Buffer.from(body.clientDataJSON, 'hex');
const clientData = JSON.parse(clientDataJSON.toString('utf-8'));
const challenge = await AttestationChallenges.findOne({
const challenge = await AttestationChallenges.findOneBy({
userId: user.id,
id: body.challengeId,
registrationChallenge: false,
@@ -149,7 +150,7 @@ export default async (ctx: Koa.Context) => {
return;
}
const securityKey = await UserSecurityKeys.findOne({
const securityKey = await UserSecurityKeys.findOneBy({
id: Buffer.from(
body.credentialId
.replace(/-/g, '+')
@@ -191,7 +192,7 @@ export default async (ctx: Koa.Context) => {
return;
}
const keys = await UserSecurityKeys.find({
const keys = await UserSecurityKeys.findBy({
userId: user.id,
});

View File

@@ -9,7 +9,7 @@ export default async (ctx: Koa.Context) => {
const code = body['code'];
try {
const pendingUser = await UserPendings.findOneOrFail({ code });
const pendingUser = await UserPendings.findOneByOrFail({ code });
const { account, secret } = await signup({
username: pendingUser.username,
@@ -20,7 +20,7 @@ export default async (ctx: Koa.Context) => {
id: pendingUser.id,
});
const profile = await UserProfiles.findOneOrFail(account.id);
const profile = await UserProfiles.findOneByOrFail({ userId: account.id });
await UserProfiles.update({ userId: profile.userId }, {
email: pendingUser.email,

View File

@@ -56,7 +56,7 @@ export default async (ctx: Koa.Context) => {
return;
}
const ticket = await RegistrationTickets.findOne({
const ticket = await RegistrationTickets.findOneBy({
code: invitationCode,
});