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 creation
|
|
|
|
|
2014-04-24 16:41:59 +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");
|
2017-06-22 08:07:25 +00:00
|
|
|
require_once("../inc/user_util.inc");
|
2010-03-30 17:46:09 +00:00
|
|
|
require_once("../inc/team.inc");
|
2018-04-04 18:47:26 +00:00
|
|
|
require_once("../inc/password_compat/password.inc");
|
2018-05-04 23:42:05 +00:00
|
|
|
require_once("../inc/consent.inc");
|
2005-08-09 18:46:53 +00:00
|
|
|
|
|
|
|
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
|
|
|
$config = get_config();
|
2006-10-19 18:09:02 +00:00
|
|
|
if (parse_bool($config, "disable_account_creation")) {
|
2013-12-29 06:50:59 +00:00
|
|
|
xml_error(ERR_ACCT_CREATION_DISABLED);
|
2005-08-09 18:46:53 +00:00
|
|
|
}
|
2013-11-26 06:07:20 +00:00
|
|
|
if (parse_bool($config, "disable_account_creation_rpc")) {
|
2013-12-29 06:50:59 +00:00
|
|
|
xml_error(ERR_ACCT_CREATION_DISABLED);
|
2013-11-26 06:07:20 +00:00
|
|
|
}
|
2005-08-09 18:46:53 +00:00
|
|
|
|
2006-10-19 18:09:02 +00:00
|
|
|
if(defined('INVITE_CODES')) {
|
2008-06-11 19:36:10 +00:00
|
|
|
$invite_code = get_str("invite_code");
|
2006-10-19 18:09:02 +00:00
|
|
|
if (!preg_match(INVITE_CODES, $invite_code)) {
|
2013-12-29 06:50:59 +00:00
|
|
|
xml_error(ERR_ATTACH_FAIL_INIT);
|
2006-10-19 18:09:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-09 18:46:53 +00:00
|
|
|
$email_addr = get_str("email_addr");
|
2008-06-11 19:36:10 +00:00
|
|
|
$email_addr = strtolower($email_addr);
|
|
|
|
$passwd_hash = get_str("passwd_hash");
|
|
|
|
$user_name = get_str("user_name");
|
2010-03-30 20:58:39 +00:00
|
|
|
$team_name = get_str("team_name", true);
|
2005-08-09 18:46:53 +00:00
|
|
|
|
2018-06-01 20:13:51 +00:00
|
|
|
$consent_flag = get_str("consent_flag", true);
|
2018-05-04 23:42:05 +00:00
|
|
|
$source = get_str("source", true);
|
|
|
|
|
2012-03-26 05:48:38 +00:00
|
|
|
if (!is_valid_user_name($user_name, $reason)) {
|
2013-12-29 06:50:59 +00:00
|
|
|
xml_error(ERR_BAD_USER_NAME, $reason);
|
2012-03-24 06:31:03 +00:00
|
|
|
}
|
|
|
|
|
2005-08-09 18:46:53 +00:00
|
|
|
if (!is_valid_email_addr($email_addr)) {
|
2013-12-29 06:50:59 +00:00
|
|
|
xml_error(ERR_BAD_EMAIL_ADDR);
|
2005-08-09 18:46:53 +00:00
|
|
|
}
|
2012-03-24 06:31:03 +00:00
|
|
|
|
2009-06-10 18:42:15 +00:00
|
|
|
if (is_banned_email_addr($email_addr)) {
|
2013-12-29 06:50:59 +00:00
|
|
|
xml_error(ERR_BAD_EMAIL_ADDR);
|
2009-06-10 18:42:15 +00:00
|
|
|
}
|
2005-08-09 18:46:53 +00:00
|
|
|
|
|
|
|
if (strlen($passwd_hash) != 32) {
|
2006-09-08 19:51:33 +00:00
|
|
|
xml_error(-1, "password hash length not 32");
|
2005-08-09 18:46:53 +00:00
|
|
|
}
|
|
|
|
|
2018-05-02 14:45:40 +00:00
|
|
|
$tmpuser = BoincUser::lookup_prev_email_addr($email_addr);
|
|
|
|
if ($tmpuser) {
|
|
|
|
xml_error(ERR_DB_NOT_UNIQUE);
|
|
|
|
}
|
|
|
|
|
2014-04-24 16:41:59 +00:00
|
|
|
$user = BoincUser::lookup_email_addr($email_addr);
|
2005-08-16 20:48:21 +00:00
|
|
|
if ($user) {
|
2018-03-13 21:49:14 +00:00
|
|
|
if ($user->passwd_hash != $passwd_hash && !password_verify($passwd_hash, $user->passwd_hash)) {
|
2013-12-29 06:50:59 +00:00
|
|
|
xml_error(ERR_DB_NOT_UNIQUE);
|
2005-08-16 20:48:21 +00:00
|
|
|
} else {
|
|
|
|
$authenticator = $user->authenticator;
|
|
|
|
}
|
|
|
|
} else {
|
2007-08-26 10:29:08 +00:00
|
|
|
$user = make_user($email_addr, $user_name, $passwd_hash, 'International');
|
2007-07-25 15:11:14 +00:00
|
|
|
if (!$user) {
|
2013-12-29 06:50:59 +00:00
|
|
|
xml_error(ERR_DB_NOT_UNIQUE);
|
2005-08-16 20:48:21 +00:00
|
|
|
}
|
2006-11-15 20:15:01 +00:00
|
|
|
|
2015-03-16 00:59:57 +00:00
|
|
|
if (defined('INVITE_CODES')) {
|
2007-07-25 15:11:14 +00:00
|
|
|
error_log("Account for '$email_addr' created using invitation code '$invite_code'");
|
2006-11-15 20:15:01 +00:00
|
|
|
}
|
2005-08-16 20:48:21 +00:00
|
|
|
|
2018-09-17 15:39:24 +00:00
|
|
|
// If the project has configured to use the CONSENT_TYPE_ENROLL, then
|
2018-06-01 20:13:51 +00:00
|
|
|
// record it.
|
2018-09-17 15:39:24 +00:00
|
|
|
list($checkct, $ctid) = check_consent_type(CONSENT_TYPE_ENROLL);
|
2018-09-28 16:34:54 +00:00
|
|
|
if ($checkct and check_termsofuse()) {
|
2018-09-17 20:23:20 +00:00
|
|
|
// As of Sept 2018, this code allows 'legacy' boinc clients to
|
2018-10-05 17:38:21 +00:00
|
|
|
// create accounts. If consent_flag is null the code creates
|
|
|
|
// an account as normal and there is no update to the consent
|
|
|
|
// DB table.
|
2018-09-28 16:34:54 +00:00
|
|
|
//
|
2018-10-05 17:38:21 +00:00
|
|
|
// Logic:
|
|
|
|
// * An old(er) BOINC Manager or third party GUI that doesn't
|
|
|
|
// * support the new consent features.
|
|
|
|
// -> consent_flag not set (NULL).
|
|
|
|
// * A new(er) BOINC GUI, the terms of use are shown and user
|
|
|
|
// * agrees.
|
|
|
|
// -> consent_flag=1
|
|
|
|
// * A new or older GUI, terms of use shown but the user not
|
|
|
|
// * not agree.
|
|
|
|
// -> no create account RPC at all
|
2018-09-17 20:23:20 +00:00
|
|
|
//
|
|
|
|
// In the future, when the majority of BOINC clients and
|
|
|
|
// Account Managers have been updated to use the consent_flag
|
|
|
|
// parameter, then this code should be revised to only allow
|
|
|
|
// clients who do use this flag to continue. I.e., if
|
|
|
|
// is_null($consent_flag) returns TRUE, then return an
|
|
|
|
// xml_error(-1, ...).
|
2018-06-01 20:13:51 +00:00
|
|
|
if ( (!is_null($consent_flag)) and $source) {
|
|
|
|
// Record the user giving consent in database - if consent_flag is 0,
|
|
|
|
// this is an 'anonymous account' and consent_not_required is
|
|
|
|
// set to 1.
|
|
|
|
if ($consent_flag==0) {
|
2018-06-15 19:54:35 +00:00
|
|
|
$rc = consent_to_a_policy($user, $ctid, 0, 1, $source);
|
2018-06-01 20:13:51 +00:00
|
|
|
} else {
|
2018-06-15 19:54:35 +00:00
|
|
|
$rc = consent_to_a_policy($user, $ctid, 1, 0, $source);
|
2018-06-01 20:13:51 +00:00
|
|
|
}
|
|
|
|
if (!$rc) {
|
|
|
|
xml_error(-1, "database error, please contact site administrators");
|
|
|
|
}
|
2018-05-04 23:42:05 +00:00
|
|
|
}
|
|
|
|
}
|
2018-06-01 20:13:51 +00:00
|
|
|
|
2018-05-04 23:42:05 +00:00
|
|
|
}
|
|
|
|
|
2010-03-30 17:46:09 +00:00
|
|
|
if ($team_name) {
|
|
|
|
$team_name = BoincDb::escape_string($team_name);
|
2010-03-30 20:58:39 +00:00
|
|
|
$team = BoincTeam::lookup("name='$team_name'");
|
2010-03-30 17:46:09 +00:00
|
|
|
if ($team && $team->joinable) {
|
|
|
|
user_join_team($team, $user);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-08 19:51:33 +00:00
|
|
|
echo " <account_out>\n";
|
2007-07-25 15:11:14 +00:00
|
|
|
echo " <authenticator>$user->authenticator</authenticator>\n";
|
2006-09-08 19:51:33 +00:00
|
|
|
echo "</account_out>\n";
|
2005-08-10 08:55:57 +00:00
|
|
|
|
2005-08-09 18:46:53 +00:00
|
|
|
?>
|