2011-04-16 23:04:23 +00:00
|
|
|
<?php
|
|
|
|
|
2012-07-18 15:23:40 +00:00
|
|
|
OC_JSON::checkSubAdminUser();
|
2012-07-07 13:27:04 +00:00
|
|
|
OCP\JSON::callCheck();
|
2011-04-16 23:04:23 +00:00
|
|
|
|
2011-04-17 11:15:55 +00:00
|
|
|
$username = $_POST["username"];
|
2011-04-16 23:04:23 +00:00
|
|
|
|
2012-10-10 16:05:34 +00:00
|
|
|
// A user shouldn't be able to delete his own account
|
|
|
|
if(OC_User::getUser() === $username) {
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2013-01-14 18:45:17 +00:00
|
|
|
if(!OC_User::isAdminUser(OC_User::getUser()) && !OC_SubAdmin::isUserAccessible(OC_User::getUser(), $username)) {
|
2012-07-19 14:35:14 +00:00
|
|
|
$l = OC_L10N::get('core');
|
2012-07-19 16:00:33 +00:00
|
|
|
OC_JSON::error(array( 'data' => array( 'message' => $l->t('Authentication error') )));
|
2012-07-19 14:35:14 +00:00
|
|
|
exit();
|
2012-07-18 15:23:40 +00:00
|
|
|
}
|
|
|
|
|
2011-04-16 23:04:23 +00:00
|
|
|
// Return Success story
|
2012-09-04 09:51:04 +00:00
|
|
|
if( OC_User::deleteUser( $username )) {
|
2011-09-23 20:22:59 +00:00
|
|
|
OC_JSON::success(array("data" => array( "username" => $username )));
|
2011-04-16 23:04:23 +00:00
|
|
|
}
|
|
|
|
else{
|
2012-09-04 09:54:04 +00:00
|
|
|
OC_JSON::error(array("data" => array( "message" => $l->t("Unable to delete user") )));
|
2011-04-16 23:04:23 +00:00
|
|
|
}
|