Merge tag '2023.9.0' into merge-upstream

This commit is contained in:
riku6460
2023-09-25 12:43:07 +09:00
1235 changed files with 19016 additions and 13835 deletions

View File

@@ -7,9 +7,8 @@ import * as OTPAuth from 'otpauth';
import { Inject, Injectable } from '@nestjs/common';
import { Endpoint } from '@/server/api/endpoint-base.js';
import { UserEntityService } from '@/core/entities/UserEntityService.js';
import type { UserProfilesRepository } from '@/models/index.js';
import type { UserProfilesRepository } from '@/models/_.js';
import { GlobalEventService } from '@/core/GlobalEventService.js';
import type { Config } from '@/config.js';
import { DI } from '@/di-symbols.js';
export const meta = {
@@ -26,13 +25,9 @@ export const paramDef = {
required: ['token'],
} as const;
// eslint-disable-next-line import/no-default-export
@Injectable()
export default class extends Endpoint<typeof meta, typeof paramDef> {
export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export
constructor(
@Inject(DI.config)
private config: Config,
@Inject(DI.userProfilesRepository)
private userProfilesRepository: UserProfilesRepository,
@@ -52,16 +47,14 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
secret: OTPAuth.Secret.fromBase32(profile.twoFactorTempSecret),
digits: 6,
token,
window: 1,
window: 5,
});
if (delta === null) {
throw new Error('not verified');
}
const backupCodes = Array.from({ length: 20 }, () => {
return new OTPAuth.Secret().base32;
});
const backupCodes = Array.from({ length: 20 }, () => new OTPAuth.Secret().base32);
await this.userProfilesRepository.update(me.id, {
twoFactorSecret: profile.twoFactorTempSecret,