From 6d56b7571553eda4c5c41f0341449d5f9cdfc143 Mon Sep 17 00:00:00 2001 From: adamch Date: Thu, 22 Nov 2007 17:35:25 +0000 Subject: [PATCH] Restore password display to go with initial application --- app/app.sig | 4 ++-- app/app.sml | 28 ++++++++++++++-------------- app/confirm.mlt | 30 ++++++++++++++---------------- app/join.mlt | 14 ++++++++------ 4 files changed, 38 insertions(+), 38 deletions(-) rewrite app/confirm.mlt (80%) diff --git a/app/app.sig b/app/app.sig index 7b17423..86f8118 100644 --- a/app/app.sig +++ b/app/app.sig @@ -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 diff --git a/app/app.sml b/app/app.sml index 1346829..f142e1b 100644 --- a/app/app.sml +++ b/app/app.sml @@ -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 diff --git a/app/confirm.mlt b/app/confirm.mlt dissimilarity index 80% index 3492118..0cc9776 100644 --- a/app/confirm.mlt +++ b/app/confirm.mlt @@ -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 => - %>

Confirmation successful

- 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: -
<% Web.html unix_passwd %>
<% - | NONE => - %>

Error confirming

- 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 + %>

Confirmation successful

+ You should hear from us within a few days from now.<% +else + %>

Error confirming

+ Did you already follow this confirmation link?<% +end; + +@footer[] %> \ No newline at end of file diff --git a/app/join.mlt b/app/join.mlt index 40a6f81..dbe8d08 100644 --- a/app/join.mlt +++ b/app/join.mlt @@ -28,13 +28,15 @@ %>

That username is already in use.

<% elseif not (App.validEmail email) then %>

Invalid e-mail address

<% - 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 - %>

Error sending confirmation e-mail

<% - else - %>

Application recorded

- Check your e-mail for a message with further instructions.<% + forward = forward, uses = uses, other = other } of + NONE => %>

Error sending confirmation e-mail

<% + | SOME unix_passwd => + %>

Application recorded

+ Check your e-mail for a message with further instructions. Save this password to use to access your new account if your application is approved: +
<% Web.html unix_passwd %>
<% + end end else val minor = $"minor" <> "" %> -- 2.20.1