2005-08-09 18:46:53 +00:00
|
|
|
<?php
|
2008-08-05 22:43:14 +00:00
|
|
|
// This file is part of BOINC.
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2008 University of California
|
|
|
|
//
|
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
2005-08-09 18:46:53 +00:00
|
|
|
|
|
|
|
// RPC handler for account lookup
|
|
|
|
|
2007-11-12 22:28:17 +00:00
|
|
|
require_once("../inc/boinc_db.inc");
|
2005-08-09 18:46:53 +00:00
|
|
|
require_once("../inc/util.inc");
|
|
|
|
require_once("../inc/email.inc");
|
|
|
|
require_once("../inc/xml.inc");
|
|
|
|
|
|
|
|
xml_header();
|
2006-09-06 20:56:55 +00:00
|
|
|
$retval = db_init_xml();
|
|
|
|
if ($retval) xml_error($retval);
|
2005-08-09 18:46:53 +00:00
|
|
|
|
|
|
|
$email_addr = get_str("email_addr");
|
2008-06-11 19:36:10 +00:00
|
|
|
$passwd_hash = get_str("passwd_hash", true);
|
2005-08-09 18:46:53 +00:00
|
|
|
|
2007-11-12 22:28:17 +00:00
|
|
|
$email_addr = BoincDb::escape_string($email_addr);
|
2007-11-13 17:21:08 +00:00
|
|
|
$user = BoincUser::lookup("email_addr='$email_addr'");
|
2005-11-26 20:56:54 +00:00
|
|
|
if (!$user) {
|
2006-09-06 20:56:55 +00:00
|
|
|
xml_error(-136);
|
2005-11-26 20:56:54 +00:00
|
|
|
}
|
|
|
|
|
2006-06-16 21:19:00 +00:00
|
|
|
if (!$passwd_hash) {
|
2006-09-06 20:56:55 +00:00
|
|
|
echo "<account_out>
|
|
|
|
<success/>
|
|
|
|
</account_out>
|
|
|
|
";
|
2006-06-16 21:19:00 +00:00
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
2005-11-26 20:56:54 +00:00
|
|
|
$auth_hash = md5($user->authenticator.$user->email_addr);
|
2005-11-19 20:33:55 +00:00
|
|
|
|
2005-11-26 20:56:54 +00:00
|
|
|
// if no password set, set password to account key
|
2005-11-19 20:33:55 +00:00
|
|
|
//
|
2005-11-26 20:56:54 +00:00
|
|
|
if (!strlen($user->passwd_hash)) {
|
|
|
|
$user->passwd_hash = $auth_hash;
|
2007-11-14 12:29:16 +00:00
|
|
|
$user->update("passwd_hash='$user->passwd_hash'");
|
2005-11-19 20:33:55 +00:00
|
|
|
}
|
|
|
|
|
2005-11-26 20:56:54 +00:00
|
|
|
// if the given password hash matches (auth+email), accept it
|
|
|
|
//
|
|
|
|
if ($user->passwd_hash == $passwd_hash || $auth_hash == $passwd_hash) {
|
2005-08-16 20:48:21 +00:00
|
|
|
echo "<account_out>\n";
|
|
|
|
echo "<authenticator>$user->authenticator</authenticator>\n";
|
|
|
|
echo "</account_out>\n";
|
2005-11-26 20:56:54 +00:00
|
|
|
} else {
|
2006-09-06 20:56:55 +00:00
|
|
|
xml_error(-206);
|
2005-08-09 18:46:53 +00:00
|
|
|
}
|
2005-08-10 08:55:57 +00:00
|
|
|
|
2005-08-09 18:46:53 +00:00
|
|
|
?>
|
|
|
|
|