Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### General
- Feat: ジョブキュー管理画面からキューの一時停止/再開ができるように
- Feat: アンテナのタイムラインから個別のノートを削除できるように
- Fix: コンパネからrootユーザーのパスワードをリセットしようとした際にエラーが通知されない問題を修正
- Feat: ノート検索で投稿日時の期間を条件に加えられるように(#16035)

### Client
Expand Down
18 changes: 16 additions & 2 deletions packages/backend/src/server/api/endpoints/admin/reset-password.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/pages/admin-user.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
Loading