mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-10 05:13:09 +02:00
fix: 登録メール送信時に重複確認を行う (#10231)
* fix: 登録メール送信時に重複確認を行う * try-catchを使う必要はない * Remove spaces
This commit is contained in:
parent
4835f0fb43
commit
a4ca127ebd
1 changed files with 19 additions and 6 deletions
|
@ -2,7 +2,7 @@ import { Inject, Injectable } from '@nestjs/common';
|
||||||
import rndstr from 'rndstr';
|
import rndstr from 'rndstr';
|
||||||
import bcrypt from 'bcryptjs';
|
import bcrypt from 'bcryptjs';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import type { RegistrationTicketsRepository, UserPendingsRepository, UserProfilesRepository, UsersRepository } from '@/models/index.js';
|
import type { RegistrationTicketsRepository, UsedUsernamesRepository, UserPendingsRepository, UserProfilesRepository, UsersRepository } from '@/models/index.js';
|
||||||
import type { Config } from '@/config.js';
|
import type { Config } from '@/config.js';
|
||||||
import { MetaService } from '@/core/MetaService.js';
|
import { MetaService } from '@/core/MetaService.js';
|
||||||
import { CaptchaService } from '@/core/CaptchaService.js';
|
import { CaptchaService } from '@/core/CaptchaService.js';
|
||||||
|
@ -15,6 +15,7 @@ import { FastifyReplyError } from '@/misc/fastify-reply-error.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import { SigninService } from './SigninService.js';
|
import { SigninService } from './SigninService.js';
|
||||||
import type { FastifyRequest, FastifyReply } from 'fastify';
|
import type { FastifyRequest, FastifyReply } from 'fastify';
|
||||||
|
import { IsNull } from 'typeorm';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SignupApiService {
|
export class SignupApiService {
|
||||||
|
@ -31,6 +32,9 @@ export class SignupApiService {
|
||||||
@Inject(DI.userPendingsRepository)
|
@Inject(DI.userPendingsRepository)
|
||||||
private userPendingsRepository: UserPendingsRepository,
|
private userPendingsRepository: UserPendingsRepository,
|
||||||
|
|
||||||
|
@Inject(DI.usedUsernamesRepository)
|
||||||
|
private usedUsernamesRepository: UsedUsernamesRepository,
|
||||||
|
|
||||||
@Inject(DI.registrationTicketsRepository)
|
@Inject(DI.registrationTicketsRepository)
|
||||||
private registrationTicketsRepository: RegistrationTicketsRepository,
|
private registrationTicketsRepository: RegistrationTicketsRepository,
|
||||||
|
|
||||||
|
@ -124,6 +128,15 @@ export class SignupApiService {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (instance.emailRequiredForSignup) {
|
if (instance.emailRequiredForSignup) {
|
||||||
|
if (await this.usersRepository.findOneBy({ usernameLower: username.toLowerCase(), host: IsNull() })) {
|
||||||
|
throw new FastifyReplyError(400, 'DUPLICATED_USERNAME');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check deleted username duplication
|
||||||
|
if (await this.usedUsernamesRepository.findOneBy({ username: username.toLowerCase() })) {
|
||||||
|
throw new FastifyReplyError(400, 'USED_USERNAME');
|
||||||
|
}
|
||||||
|
|
||||||
const code = rndstr('a-z0-9', 16);
|
const code = rndstr('a-z0-9', 16);
|
||||||
|
|
||||||
// Generate hash of password
|
// Generate hash of password
|
||||||
|
|
Loading…
Reference in a new issue