Return a 404 if attempting to delete a user that does not exist; closes #503

This commit is contained in:
Dane Everitt 2017-06-18 20:27:24 -05:00
parent 30e0495489
commit 32b639e3eb
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53

View file

@ -151,6 +151,8 @@ class UserRepository
*/ */
public function delete($id) public function delete($id)
{ {
$user = Models\User::findOrFail($id);
if (Models\Server::where('owner_id', $id)->count() > 0) { if (Models\Server::where('owner_id', $id)->count() > 0) {
throw new DisplayException('Cannot delete a user with active servers attached to thier account.'); throw new DisplayException('Cannot delete a user with active servers attached to thier account.');
} }
@ -170,7 +172,7 @@ class UserRepository
$subuser->delete(); $subuser->delete();
} }
Models\User::destroy($id); $user->delete();
DB::commit(); DB::commit();
} catch (\Exception $ex) { } catch (\Exception $ex) {
DB::rollBack(); DB::rollBack();