- try
- (match sth#fetch1 () with
- [ Some userid; None ] ->
- (* Existing user account - send reminder. *)
- template_exists#set "username" username;
- template_exists#set "hostname" hostname;
- template_exists#to_string
-
- | [ Some userid; Some invite ] ->
- (* Existing user account - resend the invite. *)
- template#set "username" username;
- template#set "hostname" hostname;
- template#set "invite" invite;
- template#to_string
-
- | _ -> assert false)
- with
- Not_found ->
- (* Add user account. *)
- let invite = random_sessionid () in
- let sth = dbh#prepare_cached "insert into users (hostid, name,
- password, email, invite) values (?, ?, ?, ?, ?)" in
- sth#execute [Some hostid; Some email; Some invite;
- Some email; Some invite];
-
- template#set "username" username;
- template#set "hostname" hostname;
- template#set "invite" invite;
- template#to_string in
+ match rows with
+ | [ userid, None ] ->
+ (* Existing user account - send reminder. *)
+ template_exists#set "username" username;
+ template_exists#set "hostname" hostname;
+ template_exists#to_string
+
+ | [ userid, Some invite ] ->
+ (* Existing user account - resend the invite. *)
+ template#set "username" username;
+ template#set "hostname" hostname;
+ template#set "invite" invite;
+ template#to_string
+
+ | [] ->
+ (* Add user account. *)
+ let invite = random_sessionid () in
+ PGSQL(dbh)
+ "insert into users (hostid, name,
+ password, email, invite) values ($hostid, $email, $invite,
+ $email, $invite)";
+
+ template#set "username" username;
+ template#set "hostname" hostname;
+ template#set "invite" invite;
+ template#to_string
+
+ | _ -> assert false in