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:
parent
41c87074e6
commit
1c67c26bd8
325 changed files with 1314 additions and 1494 deletions
|
|
@ -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,
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue