summaryrefslogtreecommitdiff
path: root/src/server/api/endpoints/email-address
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2021-10-08 13:37:02 +0900
committerGitHub <noreply@github.com>2021-10-08 13:37:02 +0900
commitb875cc994968bb334dfb9d83707e56ab3971a0d1 (patch)
tree5655892af829ecad9f040624f8b6cd31410284f9 /src/server/api/endpoints/email-address
parentupdate dependencies (diff)
downloadmisskey-b875cc994968bb334dfb9d83707e56ab3971a0d1.tar.gz
misskey-b875cc994968bb334dfb9d83707e56ab3971a0d1.tar.bz2
misskey-b875cc994968bb334dfb9d83707e56ab3971a0d1.zip
feat: アカウント作成にメールアドレス必須にするオプション (#7856)
* feat: アカウント作成にメールアドレス必須にするオプション * ui * fix bug * fix bug * fix bug * :art:
Diffstat (limited to 'src/server/api/endpoints/email-address')
-rw-r--r--src/server/api/endpoints/email-address/available.ts37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/server/api/endpoints/email-address/available.ts b/src/server/api/endpoints/email-address/available.ts
new file mode 100644
index 0000000000..65fe6f9178
--- /dev/null
+++ b/src/server/api/endpoints/email-address/available.ts
@@ -0,0 +1,37 @@
+import $ from 'cafy';
+import define from '../../define';
+import { UserProfiles } from '@/models/index';
+
+export const meta = {
+ tags: ['users'],
+
+ requireCredential: false as const,
+
+ params: {
+ emailAddress: {
+ validator: $.str
+ }
+ },
+
+ res: {
+ type: 'object' as const,
+ optional: false as const, nullable: false as const,
+ properties: {
+ available: {
+ type: 'boolean' as const,
+ optional: false as const, nullable: false as const,
+ }
+ }
+ }
+};
+
+export default define(meta, async (ps) => {
+ const exist = await UserProfiles.count({
+ emailVerified: true,
+ email: ps.emailAddress,
+ });
+
+ return {
+ available: exist === 0
+ };
+});