use proper return codes and handle failure cases
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
parent
2507e7459d
commit
485d6d6577
3 changed files with 21 additions and 7 deletions
|
@ -567,7 +567,8 @@ class UsersController extends Controller {
|
|||
'data' => array(
|
||||
'message' => (string)$this->l10n->t('Error while disabling user.')
|
||||
)
|
||||
)
|
||||
),
|
||||
Http::STATUS_FORBIDDEN
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -624,7 +625,8 @@ class UsersController extends Controller {
|
|||
'data' => array(
|
||||
'message' => (string)$this->l10n->t('Error while enabling user.')
|
||||
)
|
||||
)
|
||||
),
|
||||
Http::STATUS_FORBIDDEN
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -949,7 +949,15 @@ $(document).ready(function () {
|
|||
OC.dialogs.alert(result.data.message, t('settings', 'Error while changing status of {user}', {user: uid}));
|
||||
}
|
||||
}
|
||||
);
|
||||
).fail(function(result){
|
||||
var message = 'Unknown error';
|
||||
if( result.responseJSON &&
|
||||
result.responseJSON.data &&
|
||||
result.responseJSON.data.message) {
|
||||
message = result.responseJSON.data.message;
|
||||
}
|
||||
OC.dialogs.alert(message, t('settings', 'Error while changing status of {user}', {user: uid}));
|
||||
});
|
||||
});
|
||||
|
||||
// init the quota field select box after it is shown the first time
|
||||
|
|
|
@ -2532,7 +2532,8 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
'data' => [
|
||||
'message' => 'Error while disabling user.',
|
||||
],
|
||||
]
|
||||
],
|
||||
Http::STATUS_FORBIDDEN
|
||||
);
|
||||
$response = $this->getController(true)->disable('abc');
|
||||
$this->assertEquals($expectedResponse, $response);
|
||||
|
@ -2569,7 +2570,8 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
'data' => [
|
||||
'message' => 'Error while disabling user.',
|
||||
],
|
||||
]
|
||||
],
|
||||
Http::STATUS_FORBIDDEN
|
||||
);
|
||||
$response = $this->getController(false)->disable('abc');
|
||||
$this->assertEquals($expectedResponse, $response);
|
||||
|
@ -2746,7 +2748,8 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
'data' => [
|
||||
'message' => 'Error while enabling user.',
|
||||
],
|
||||
]
|
||||
],
|
||||
Http::STATUS_FORBIDDEN
|
||||
);
|
||||
$response = $this->getController(true)->enable('abc');
|
||||
$this->assertEquals($expectedResponse, $response);
|
||||
|
@ -2783,7 +2786,8 @@ class UsersControllerTest extends \Test\TestCase {
|
|||
'data' => [
|
||||
'message' => 'Error while enabling user.',
|
||||
],
|
||||
]
|
||||
],
|
||||
Http::STATUS_FORBIDDEN
|
||||
);
|
||||
$response = $this->getController(false)->enable('abc');
|
||||
$this->assertEquals($expectedResponse, $response);
|
||||
|
|
Loading…
Reference in a new issue