diff --git a/api.php b/api.php index 2f8c4b5..53d56ae 100644 --- a/api.php +++ b/api.php @@ -255,18 +255,22 @@ switch($request[0]) { switch($request[1]) { /* APIDOC: account/create 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) */ case 'create': $user = trim($_POST['username']); $pass = trim($_POST['password']); $email = trim($_POST['email']); - if($user && $pass) { - $a=account_create($user,$pass); + if($user) { + if($pass) $p=$pass; else $p=NULL; + $a=account_create($user,$p); if(is_array($a)) { if($email) account_set_email($a['id'],$email); + else if(isEmailAddress($user)) + account_set_email($a['id'],$user); + $account=account_load($a['id']); $ret['status']="ok"; $ret['account']=$account;