Restore password display to go with initial application
authoradamch <adamch>
Thu, 22 Nov 2007 17:35:25 +0000 (17:35 +0000)
committeradamch <adamch>
Thu, 22 Nov 2007 17:35:25 +0000 (17:35 +0000)
app/app.sig
app/app.sml
app/confirm.mlt
app/join.mlt

index 7b17423..86f8118 100644 (file)
@@ -12,11 +12,11 @@ sig
     type application = { name : string, rname : string, gname : string option, email : string,
                         forward : bool, uses : string, other : string }
 
-    val apply : application -> bool
+    val apply : application -> string option
 
     val validEmail : string -> bool
     val validUser : string -> bool
     val userExists : string -> bool
 
-    val confirm : int * string -> string option
+    val confirm : int * string -> bool
 end
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
dissimilarity index 80%
index 3492118..0cc9776 100644 (file)
@@ -1,16 +1,14 @@
-<% @header [("title", ["Confirm application"])];
-
-val id = Web.stoi ($"id");
-val passwd = $"p";
-
-switch App.confirm (id, passwd) of
-         SOME unix_passwd =>
-               %><h3><b>Confirmation successful</b></h3>
-               You should hear from us within a few days from now.  Save this password, to use to access our servers if your application is approved:
-               <blockquote><tt><% Web.html unix_passwd %></tt></blockquote><%
-       | NONE =>
-               %><h3><b>Error confirming</b></h3>
-                       Did you already follow this confirmation link?<%
-end;
-
-@footer[] %>
\ No newline at end of file
+<% @header [("title", ["Confirm application"])];
+
+val id = Web.stoi ($"id");
+val passwd = $"p";
+
+if App.confirm (id, passwd) then
+   %><h3><b>Confirmation successful</b></h3>
+   You should hear from us within a few days from now.<%
+else
+   %><h3><b>Error confirming</b></h3>
+   Did you already follow this confirmation link?<%
+end;
+
+@footer[] %>
\ No newline at end of file
index 40a6f81..dbe8d08 100644 (file)
                %><h3>That username is already in use.</b><h3><%
        elseif not (App.validEmail email) then
                %><h3>Invalid e-mail address</h3><%
-       elseif not (App.apply { name = name, rname = rname, email = email,
+       else switch App.apply { name = name, rname = rname, email = email,
                                gname = (case gname of "" => NONE | _ => SOME gname),
-                               forward = forward, uses = uses, other = other }) then
-               %><h3>Error sending confirmation e-mail</h3><%
-       else
-               %><h3>Application recorded</h3>
-               Check your e-mail for a message with further instructions.<%
+                               forward = forward, uses = uses, other = other } of
+                 NONE => %><h3>Error sending confirmation e-mail</h3><%
+               | SOME unix_passwd =>
+                       %><h3>Application recorded</h3>
+                       Check your e-mail for a message with further instructions.  <b>Save this password to use to access your new account if your application is approved</b>:
+                       <blockquote><tt><% Web.html unix_passwd %></tt></blockquote><%
+               end
        end
 else
        val minor = $"minor" <> "" %>