Skip to content

Commit

Permalink
Disallow inviting employee or system accounts.
Browse files Browse the repository at this point in the history
  • Loading branch information
kjoconnor committed Apr 20, 2016
1 parent 543486c commit 98b7848
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions r2/r2/controllers/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4882,6 +4882,11 @@ def POST_adddeveloper(self, form, jquery, client, account):
c.errors.add(errors.DEVELOPER_FIRST_PARTY_APP, field='name')
form.set_error(errors.DEVELOPER_FIRST_PARTY_APP, 'name')
return
if ((account.employee or account == Account.system_user()) and
not c.user_is_admin):
c.errors.add(errors.DEVELOPER_PRIVILEGED_ACCOUNT, field='name')
form.set_error(errors.DEVELOPER_PRIVILEGED_ACCOUNT, 'name')
return
if client.has_developer(account):
c.errors.add(errors.DEVELOPER_ALREADY_ADDED, field='name')
form.set_error(errors.DEVELOPER_ALREADY_ADDED, 'name')
Expand Down
1 change: 1 addition & 0 deletions r2/r2/lib/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
('DEVELOPER_ALREADY_ADDED', _('already added')),
('TOO_MANY_DEVELOPERS', _('too many developers')),
('DEVELOPER_FIRST_PARTY_APP', _('this app can not be modified from this interface')),
('DEVELOPER_PRIVILEGED_ACCOUNT', _('you cannot add this account from this interface')),
('INVALID_MODHASH', _("invalid modhash")),
('ALREADY_MODERATOR', _('that user is already a moderator')),
('CANT_RESTRICT_MODERATOR', _("You can't perform that action because that user is a moderator.")),
Expand Down
1 change: 1 addition & 0 deletions r2/r2/templates/prefapps.html
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ <h3>${app._id}</h3>
${error_field('USER_DOESNT_EXIST', 'name')}
${error_field('NO_USER', 'name')}
${error_field('DEVELOPER_FIRST_PARTY_APP', 'name')}
${error_field('DEVELOPER_PRIVILEGED_ACCOUNT', 'name')}
<span class="status"></span>
</form>
</td>
Expand Down

0 comments on commit 98b7848

Please sign in to comment.