forked from science-ation/science-ation
Update docs for account/edit, and tweak link_username_to_email
This commit is contained in:
parent
7d6d1851cd
commit
c0299dc870
@ -442,7 +442,7 @@ function account_remove_role($accounts_id, $roles_id, $conferences_id){
|
||||
// A function for handling updates of any fields that can be modified through an API call.
|
||||
// returns 'ok' on success, error message otherwise.
|
||||
function account_update_info($fields){
|
||||
if(array_key_exists('accounts_id', $_SESSION)){
|
||||
if($_SESSION['accounts_id']) {
|
||||
$accounts_id = $_SESSION['accounts_id'];
|
||||
}else{
|
||||
return 'you must be logged in to change your account settings';
|
||||
@ -480,7 +480,17 @@ function account_update_info($fields){
|
||||
|
||||
case 'link_username_to_email':
|
||||
if(in_array($value, array('yes', 'no'))){
|
||||
if($value=='yes') {
|
||||
//if its yes, we can only do it if username==email
|
||||
if($fields['username']==$fields['email']) {
|
||||
$updates[$index] = $value;
|
||||
} else {
|
||||
$message="username and email must match for link_username_toemail";
|
||||
}
|
||||
}
|
||||
else {
|
||||
$updates[$index] = $value;
|
||||
}
|
||||
}else{
|
||||
$message = '"link_username_to_email" must be either a "yes" or "no" value';
|
||||
}
|
||||
|
21
api.php
21
api.php
@ -287,6 +287,7 @@ switch($request[0]) {
|
||||
|
||||
/* APIDOC: account/view
|
||||
description(view account information for currently logged in account)
|
||||
object(account: {id,username,link_username_to_email enum(no,yes),passwordset date,email,pendignemail,superuser enum(no,yes),deleted enum(no,yes),deleted_datetime datetime,created datetime})
|
||||
return(account array)
|
||||
*/
|
||||
case 'view':
|
||||
@ -304,21 +305,19 @@ switch($request[0]) {
|
||||
/* APIDOC: account/edit
|
||||
description(edits an account)
|
||||
post(account array)
|
||||
object(account: {id,username,password,link_username_to_email enum(no,yes),email})
|
||||
return(account array)
|
||||
*/
|
||||
case 'edit':
|
||||
if(isset($_SESSION['accounts_id'])) {
|
||||
|
||||
// grab the relevant keys from $_POST
|
||||
$params = array();
|
||||
foreach($_POST as $key => $value){
|
||||
if(in_array($key, array('username', 'password', 'email', 'link_username_to_email'))){
|
||||
$params[$key] = $_POST[$key];
|
||||
}
|
||||
$account=json_decode($_POST['account'],true);
|
||||
if($account['id']!=$_SESSION['accounts_id']) {
|
||||
$ret['status'] = "error";
|
||||
$ret['error'] = "Account id mismatch";
|
||||
break;
|
||||
}
|
||||
|
||||
if(count($params) > 0){
|
||||
$result = account_update_info($params);
|
||||
$result = account_update_info($account);
|
||||
if($result == 'ok'){
|
||||
$a = account_load($_SESSION['accounts_id']);
|
||||
$ret['status'] = 'ok';
|
||||
@ -328,10 +327,6 @@ switch($request[0]) {
|
||||
$ret['status'] = "error";
|
||||
$ret['error'] = $result;
|
||||
}
|
||||
}else{
|
||||
$ret['status'] = "error";
|
||||
$ret['error'] = "No field values passed";
|
||||
}
|
||||
|
||||
}else{
|
||||
$ret['status']="error";
|
||||
|
Loading…
Reference in New Issue
Block a user