Add /api/sign_up/send_verification_email.json endpoint, add step 3 of sign up process...
[ndcode_site.git] / api / sign_up / create_account.json.jst
index ba00760..c3c74b6 100644 (file)
@@ -8,7 +8,7 @@ return async env => {
   post_request(
     // env
     env,
-    // api
+    // endpoint
     '/api/sign_up/create_account',
     // func
     async (verification_code, details) => {
@@ -21,6 +21,16 @@ return async env => {
         password: details.password.slice(0, 256),
         contact_me: details.contact_me ? true : false
       }
+      if (
+        verification_code.length < 6 ||
+          details.given_names.length === 0 ||
+          details.password.length < 8
+      )
+        throw new Problem(
+          'Bad request',
+          'Minimum length check failed',
+          400
+        )
 
       let transaction = await env.site.database.Transaction()
       try {
@@ -31,7 +41,7 @@ return async env => {
         if (captcha === undefined || XDate.now() >= captcha.get('expires'))
           throw new Problem(
             'No verification image in session',
-            `Please call the "/api/verification_image.png" endpoint to create a verification image, in same session as the "/api/sign_up.json" call and less than one hour prior.`,
+            `Please call the "/api/verification_image.png" endpoint to create a verification image, in same session as the "/api/sign_up/create_account.json" call and less than one hour prior.`,
             418
           )