Make password optional for create account (it'll pick a random one if not specified)

This commit is contained in:
james 2011-02-23 16:42:08 +00:00
parent a484939f1b
commit 79baaa37b6

10
api.php
View File

@ -255,18 +255,22 @@ switch($request[0]) {
switch($request[1]) { switch($request[1]) {
/* APIDOC: account/create /* APIDOC: account/create
description(creates an account) description(creates an account)
post(username varchar(64), password varchar(64), email varchar(64) optional) post(username varchar(64), password varchar(64) optional, email varchar(64) optional)
return(account array) return(account array)
*/ */
case 'create': case 'create':
$user = trim($_POST['username']); $user = trim($_POST['username']);
$pass = trim($_POST['password']); $pass = trim($_POST['password']);
$email = trim($_POST['email']); $email = trim($_POST['email']);
if($user && $pass) { if($user) {
$a=account_create($user,$pass); if($pass) $p=$pass; else $p=NULL;
$a=account_create($user,$p);
if(is_array($a)) { if(is_array($a)) {
if($email) if($email)
account_set_email($a['id'],$email); account_set_email($a['id'],$email);
else if(isEmailAddress($user))
account_set_email($a['id'],$user);
$account=account_load($a['id']); $account=account_load($a['id']);
$ret['status']="ok"; $ret['status']="ok";
$ret['account']=$account; $ret['account']=$account;