Create an initial user during install, and grant owner, moderator and administrator roles.
This commit is contained in:
parent
37b106d49c
commit
44462ac617
74
install.php
74
install.php
@ -31,6 +31,7 @@
|
||||
* @author Robin Millette <millette@controlyourself.ca>
|
||||
* @author Sarven Capadisli <csarven@status.net>
|
||||
* @author Tom Adams <tom@holizz.com>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @license GNU Affero General Public License http://www.gnu.org/licenses/
|
||||
* @version 0.9.x
|
||||
* @link http://status.net
|
||||
@ -490,15 +491,25 @@ function showForm()
|
||||
<p class="form_guide">Database name</p>
|
||||
</li>
|
||||
<li>
|
||||
<label for="username">Username</label>
|
||||
<label for="username">DB username</label>
|
||||
<input type="text" id="username" name="username" />
|
||||
<p class="form_guide">Database username</p>
|
||||
</li>
|
||||
<li>
|
||||
<label for="password">Password</label>
|
||||
<label for="password">DB password</label>
|
||||
<input type="password" id="password" name="password" />
|
||||
<p class="form_guide">Database password (optional)</p>
|
||||
</li>
|
||||
<li>
|
||||
<label for="admin_nickname">Administrator nickname</label>
|
||||
<input type="text" id="admin_nickname" name="admin_nickname" />
|
||||
<p class="form_guide">Nickname for the initial StatusNet user (administrator)</p>
|
||||
</li>
|
||||
<li>
|
||||
<label for="initial_user_password">Administrator password</label>
|
||||
<input type="password" id="admin_password" name="admin_password" />
|
||||
<p class="form_guide">Password for the initial StatusNet user (administrator)</p>
|
||||
</li>
|
||||
</ul>
|
||||
<input type="submit" name="submit" class="submit" value="Submit" />
|
||||
</fieldset>
|
||||
@ -521,6 +532,10 @@ function handlePost()
|
||||
$password = $_POST['password'];
|
||||
$sitename = $_POST['sitename'];
|
||||
$fancy = !empty($_POST['fancy']);
|
||||
|
||||
$adminNick = $_POST['admin_nickname'];
|
||||
$adminPass = $_POST['admin_password'];
|
||||
|
||||
$server = $_SERVER['HTTP_HOST'];
|
||||
$path = substr(dirname($_SERVER['PHP_SELF']), 1);
|
||||
|
||||
@ -552,6 +567,16 @@ STR;
|
||||
$fail = true;
|
||||
}
|
||||
|
||||
if (empty($adminNick)) {
|
||||
updateStatus("No initial StatusNet user nickname specified.", true);
|
||||
$fail = true;
|
||||
}
|
||||
|
||||
if (empty($adminPass)) {
|
||||
updateStatus("No initial StatusNet user password specified.", true);
|
||||
$fail = true;
|
||||
}
|
||||
|
||||
if ($fail) {
|
||||
showForm();
|
||||
return;
|
||||
@ -574,13 +599,29 @@ STR;
|
||||
return;
|
||||
}
|
||||
|
||||
// Okay, cross fingers and try to register an initial user
|
||||
if (registerInitialUser($adminNick, $adminPass)) {
|
||||
updateStatus(
|
||||
"An initial user with the administrator role has been created."
|
||||
);
|
||||
} else {
|
||||
updateStatus(
|
||||
"Could not create initial StatusNet user (administrator).",
|
||||
true
|
||||
);
|
||||
showForm();
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
TODO https needs to be considered
|
||||
*/
|
||||
$link = "http://".$server.'/'.$path;
|
||||
|
||||
updateStatus("StatusNet has been installed at $link");
|
||||
updateStatus("You can visit your <a href='$link'>new StatusNet site</a>.");
|
||||
updateStatus(
|
||||
"You can visit your <a href='$link'>new StatusNet site</a> (login as '$adminNick')."
|
||||
);
|
||||
}
|
||||
|
||||
function Pgsql_Db_installer($host, $database, $username, $password)
|
||||
@ -756,6 +797,33 @@ function runDbScript($filename, $conn, $type = 'mysqli')
|
||||
return true;
|
||||
}
|
||||
|
||||
function registerInitialUser($nickname, $password)
|
||||
{
|
||||
define('STATUSNET', true);
|
||||
define('LACONICA', true); // compatibility
|
||||
|
||||
require_once INSTALLDIR . '/lib/common.php';
|
||||
|
||||
$user = User::register(
|
||||
array('nickname' => $nickname,
|
||||
'password' => $password,
|
||||
'fullname' => $nickname
|
||||
)
|
||||
);
|
||||
|
||||
if (empty($user)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// give initial user carte blanche
|
||||
|
||||
$user->grantRole('owner');
|
||||
$user->grantRole('moderator');
|
||||
$user->grantRole('administrator');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
?>
|
||||
<?php echo"<?"; ?> xml version="1.0" encoding="UTF-8" <?php echo "?>"; ?>
|
||||
<!DOCTYPE html
|
||||
|
Loading…
Reference in New Issue
Block a user