X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=scripts%2Finvite_user_confirm.ml;h=9db853a1be9bc5d7eb35db98db39e69f7d5deb1f;hb=c912392e889fc28c6444b7e38cd92b9d0fd960a8;hp=e44265cf9cd62e285131cb6e835309d9ead2ef59;hpb=4a0ade944a434120218f2083d5ea7558b3e9cf08;p=cocanwiki.git diff --git a/scripts/invite_user_confirm.ml b/scripts/invite_user_confirm.ml index e44265c..9db853a 100644 --- a/scripts/invite_user_confirm.ml +++ b/scripts/invite_user_confirm.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: invite_user_confirm.ml,v 1.5 2006/03/27 18:09:46 rich Exp $ + * $Id: invite_user_confirm.ml,v 1.6 2006/03/28 13:20:00 rich Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -36,21 +36,19 @@ let run r (q : cgi) dbh hostid { hostname = hostname } _ = let invite = q#param "invite" in (* Verify the username, invite combination. *) - let sth = dbh#prepare_cached "select email, id from users - where hostid = ? and - name = ? and invite = ?" in - sth#execute [Some hostid; Some username; Some invite]; + let rows = PGSQL(dbh) "select email, id from users + where hostid = $hostid and + name = $username and invite = $invite" in let email, userid = - try - match sth#fetch1 () with - [ Some email; Some userid ] -> Some email, userid - | [ None; Some userid ] -> None, userid - | _ -> assert false - with Not_found -> - error ~title:"Already signed up" - dbh hostid q "It looks like you have already used your invitation."; - return () in + match rows with + | [ Some email; userid ] -> Some email, userid + | [ None; userid ] -> None, userid + | [] -> + error ~title:"Already signed up" + dbh hostid q "It looks like you have already used your invitation."; + return () + | _ -> assert false in let password1 = q#param "password1" in let password2 = q#param "password2" in @@ -70,12 +68,10 @@ let run r (q : cgi) dbh hostid { hostname = hostname } _ = let password = password1 in (* Change the password. *) - let sth = - dbh#prepare_cached - "update users set password = ?, invite = null, - force_password_change = false - where hostid = ? and id = ?" in - sth#execute [Some password; Some hostid; Some userid]; + PGSQL(dbh) + "update users set password = $password, invite = null, + force_password_change = false + where hostid = $hostid and id = $userid"; (* Send email to this user. *) (match email with