fix: コンパネからパスワードリセットした時に発生したエラーをダイアログで出す (#17513)

Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
This commit is contained in:
おさむのひと 2026-06-03 09:04:08 +09:00 committed by GitHub
commit eed6c3654f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 18 additions and 3 deletions

View file

@ -3,6 +3,7 @@
### General
- Feat: ジョブキュー管理画面からキューの一時停止/再開ができるように
- Feat: アンテナのタイムラインから個別のノートを削除できるように
- Fix: コンパネからrootユーザーのパスワードをリセットしようとした際にエラーが通知されない問題を修正
- Feat: ノート検索で投稿日時の期間を条件に加えられるように(#16035)
### Client

View file

@ -6,6 +6,7 @@
import { Inject, Injectable } from '@nestjs/common';
import bcrypt from 'bcryptjs';
import { Endpoint } from '@/server/api/endpoint-base.js';
import { ApiError } from '@/server/api/error.js';
import type { UsersRepository, UserProfilesRepository, MiMeta } from '@/models/_.js';
import { DI } from '@/di-symbols.js';
import { secureRndstr } from '@/misc/secure-rndstr.js';
@ -18,6 +19,19 @@ export const meta = {
requireModerator: true,
kind: 'write:admin:reset-password',
errors: {
noSuchUser: {
message: 'No such user.',
code: 'NO_SUCH_USER',
id: 'ccafc7fe-5074-4edd-9dc0-8ef9ef6a701d',
},
cannotResetPasswordOfRootUser: {
message: 'Cannot reset password of the root user.',
code: 'CANNOT_RESET_PASSWORD_OF_ROOT_USER',
id: 'f28fc207-42ca-44c7-a577-44b4f0ec5999',
},
},
res: {
type: 'object',
optional: false, nullable: false,
@ -58,11 +72,11 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
const user = await this.usersRepository.findOneBy({ id: ps.userId });
if (user == null) {
throw new Error('user not found');
throw new ApiError(meta.errors.noSuchUser);
}
if (this.serverSettings.rootUserId === user.id) {
throw new Error('cannot reset password of root');
throw new ApiError(meta.errors.cannotResetPasswordOfRootUser);
}
const passwd = secureRndstr(8);

View file

@ -334,7 +334,7 @@ async function resetPassword() {
if (confirm.canceled) {
return;
} else {
const { password } = await misskeyApi('admin/reset-password', {
const { password } = await os.apiWithDialog('admin/reset-password', {
userId: user.value.id,
});
os.alert({