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
^(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);
mwrite ("&p=");
mwrite passwd;
mwrite ("\n")),
- id)
+ id) then
+ SOME unix_passwd
+ else
+ NONE
end
| _ => raise Fail "Bad next sequence val"
end
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
-<% @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
%><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" <> "" %>