mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-07-28 15:54:37 +02:00
fix: コンパネからパスワードリセットした時に発生したエラーをダイアログで出す (#17513)
Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user