mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-28 18:48:31 +01:00
Mod: バリデーションを追加
This commit is contained in:
parent
b95fb5410c
commit
4893f663ff
2 changed files with 15 additions and 0 deletions
|
@ -166,6 +166,13 @@ export class EmailService {
|
||||||
available: boolean;
|
available: boolean;
|
||||||
reason: null | 'used' | 'format' | 'disposable' | 'mx' | 'smtp' | 'banned' | 'network' | 'blacklist' | 'allowedOnly';
|
reason: null | 'used' | 'format' | 'disposable' | 'mx' | 'smtp' | 'banned' | 'network' | 'blacklist' | 'allowedOnly';
|
||||||
}> {
|
}> {
|
||||||
|
if (this.utilityService.validateEmailFormat(emailAddress)) {
|
||||||
|
return {
|
||||||
|
available: false,
|
||||||
|
reason: 'format',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const exist = await this.userProfilesRepository.countBy({
|
const exist = await this.userProfilesRepository.countBy({
|
||||||
emailVerified: true,
|
emailVerified: true,
|
||||||
email: emailAddress,
|
email: emailAddress,
|
||||||
|
|
|
@ -39,6 +39,14 @@ export class UtilityService {
|
||||||
return this.punyHost(uri) === this.toPuny(this.config.host);
|
return this.punyHost(uri) === this.toPuny(this.config.host);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// メールアドレスのバリデーションを行う
|
||||||
|
// https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address
|
||||||
|
@bindThis
|
||||||
|
public validateEmailFormat(email: string): boolean {
|
||||||
|
const regexp = /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
|
||||||
|
return regexp.test(email);
|
||||||
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public isBlockedHost(blockedHosts: string[], host: string | null): boolean {
|
public isBlockedHost(blockedHosts: string[], host: string | null): boolean {
|
||||||
if (host == null) return false;
|
if (host == null) return false;
|
||||||
|
|
Loading…
Reference in a new issue