Resolve #365
This commit is contained in:
		| @@ -29,14 +29,14 @@ export const meta = { | ||||
|  | ||||
| 	params: { | ||||
| 		name: { | ||||
| 			validator: $.optional.nullable.str.pipe(Users.isValidName), | ||||
| 			validator: $.optional.nullable.use(Users.validateName), | ||||
| 			desc: { | ||||
| 				'ja-JP': '名前(ハンドルネームやニックネーム)' | ||||
| 			} | ||||
| 		}, | ||||
|  | ||||
| 		description: { | ||||
| 			validator: $.optional.nullable.str.pipe(Users.isValidDescription), | ||||
| 			validator: $.optional.nullable.use(Users.validateDescription), | ||||
| 			desc: { | ||||
| 				'ja-JP': 'アカウントの説明や自己紹介' | ||||
| 			} | ||||
| @@ -50,14 +50,14 @@ export const meta = { | ||||
| 		}, | ||||
|  | ||||
| 		location: { | ||||
| 			validator: $.optional.nullable.str.pipe(Users.isValidLocation), | ||||
| 			validator: $.optional.nullable.use(Users.validateLocation), | ||||
| 			desc: { | ||||
| 				'ja-JP': '住んでいる地域、所在' | ||||
| 			} | ||||
| 		}, | ||||
|  | ||||
| 		birthday: { | ||||
| 			validator: $.optional.nullable.str.pipe(Users.isValidBirthday), | ||||
| 			validator: $.optional.nullable.use(Users.validateBirthday), | ||||
| 			desc: { | ||||
| 				'ja-JP': '誕生日 (YYYY-MM-DD形式)' | ||||
| 			} | ||||
|   | ||||
| @@ -44,7 +44,7 @@ export const meta = { | ||||
| 		}, | ||||
|  | ||||
| 		text: { | ||||
| 			validator: $.optional.str.pipe(MessagingMessages.isValidText) | ||||
| 			validator: $.optional.str.pipe(MessagingMessages.validateText) | ||||
| 		}, | ||||
|  | ||||
| 		fileId: { | ||||
|   | ||||
| @@ -9,7 +9,7 @@ export const meta = { | ||||
|  | ||||
| 	params: { | ||||
| 		username: { | ||||
| 			validator: $.str.pipe(Users.validateUsername) | ||||
| 			validator: $.use(Users.validateLocalUsername) | ||||
| 		} | ||||
| 	} | ||||
| }; | ||||
|   | ||||
| @@ -66,7 +66,7 @@ export const meta = { | ||||
| }; | ||||
|  | ||||
| export default define(meta, async (ps, me) => { | ||||
| 	const isUsername = Users.validateUsername(ps.query.replace('@', ''), !ps.localOnly); | ||||
| 	const isUsername = ps.localOnly ? Users.validateLocalUsername.ok(ps.query.replace('@', '')) : Users.validateRemoteUsername.ok(ps.query.replace('@', '')); | ||||
|  | ||||
| 	let users: User[] = []; | ||||
|  | ||||
|   | ||||
| @@ -58,13 +58,13 @@ export default async (ctx: Koa.BaseContext) => { | ||||
| 	} | ||||
|  | ||||
| 	// Validate username | ||||
| 	if (!Users.validateUsername(username)) { | ||||
| 	if (!Users.validateLocalUsername.ok(username)) { | ||||
| 		ctx.status = 400; | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	// Validate password | ||||
| 	if (!Users.validatePassword(password)) { | ||||
| 	if (!Users.validatePassword.ok(password)) { | ||||
| 		ctx.status = 400; | ||||
| 		return; | ||||
| 	} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 syuilo
					syuilo