Restore password display to go with initial application
[bpt/portal.git] / app / app.sml
index 1346829..f142e1b 100644 (file)
@@ -124,7 +124,7 @@ fun apply {name, rname, gname, email, forward, uses, other} =
                                    ^(C.stringToSql email), ^(C.boolToSql forward), ^(C.stringToSql uses),
                                    ^(C.stringToSql other), ^(C.stringToSql passwd), 0, CURRENT_TIMESTAMP,
                                    '', ^(C.stringToSql unix_passwd))`);
-               sendMail (email, "Confirm membership application",
+               if sendMail (email, "Confirm membership application",
                             "We've received a request to join the Internet Hosting Cooperative (hcoop.net) with this e-mail address.",
                          fn mwrite => (mwrite ("To confirm this application, visit ");
                                        mwrite (baseUrl);
@@ -133,7 +133,10 @@ fun apply {name, rname, gname, email, forward, uses, other} =
                                        mwrite ("&p=");
                                        mwrite passwd;
                                        mwrite ("\n")),
-                            id)
+                            id) then
+                   SOME unix_passwd
+               else
+                   NONE
            end
       | _ => raise Fail "Bad next sequence val"
     end
@@ -169,19 +172,16 @@ fun confirm (id, passwd) =
        val db = getDb ()
     in
        case C.oneOrNoRows db ($`SELECT unix_passwd FROM MemberApp WHERE id = ^(C.intToSql id) AND passwd = ^(C.stringToSql passwd) AND status = 0`) of
-           SOME [unix_passwd] =>
+           SOME [_] =>
            (C.dml db ($`UPDATE MemberApp SET status = 1, confirmed = CURRENT_TIMESTAMP WHERE id = ^(C.intToSql id)`);
-            if sendMail ("board@hcoop.net",
-                         "New membership application",
-                         "We've received a new request to join hcoop.",
-                      fn mwrite => (mwrite ("Open applications: ");
-                                    mwrite (portalUrl);
-                                    mwrite ("apps")),
-                         id) then
-                SOME (C.stringFromSql unix_passwd)
-            else
-                NONE)
-         | NONE => NONE
+            sendMail ("board@hcoop.net",
+                      "New membership application",
+                      "We've received a new request to join hcoop.",
+                   fn mwrite => (mwrite ("Open applications: ");
+                                 mwrite (portalUrl);
+                                 mwrite ("apps")),
+                      id))
+         | NONE => false
     end
 
 end