zulip/zerver
Mateusz Mandera 586a5facc9 models: Add is_realm_admin and is_guest setters.
Fixes #13452.

The migration from UserProfile.is_realm_admin/UserProfile.is_guest in
e10361a832 broke our LDAP-based support
for setting a user's role via LDAP properties, which relied on setting
those fields.  Because the django-auth-ldap feature powering that only
supports booleans (and in any case, we don't want to expose constants
like `ROLE_REALM_ADMINISTRATOR` to the LDAP configuration interface),
it makes sense to provide setters for these legacy fields for
backwards-compatibility.

We lint against using these setters directly in Zulip's codebase
directly.  The issue with using these is that when changing user's
.role we want to create appropriate RealmAuditLog entries and send
events. This isn't possible when using these setters - the log entries
and events should be created if the role change in the UserProfile is
actually save()-ed to the database - and on the level of the setter
function, it's not known whether the change will indeed be saved.

It would have to be somehow figured out on the level of post_save
signal handlers, but it doesn't seem like a good design to have such
complexity there, for the sake of setters that generally shouldn't be
used anyway - because we prefer the do_change_is_* functions.

The purpose of this change is narrowly to handle use cases like the
setattr on these boolean properties.
2019-12-09 11:54:01 -08:00
..
data_import slack import: Map Slack guest users to Zulip guests. 2019-11-12 12:12:59 -08:00
lib openapi: Specify securityScheme for the API in root level. 2019-12-06 11:19:08 -08:00
management send_custom_email: Add support for specifying reply-to. 2019-11-18 17:34:01 -08:00
migrations CVE-2019-18933: Fix insecure account creation via social authentication. 2019-11-21 10:23:37 -08:00
openapi openapi: Specify responses for users/me/subscriptions PATCH operation. 2019-12-06 11:19:08 -08:00
templatetags openapi: Pass api_url to curl example generation. 2019-08-17 11:35:08 -07:00
tests models: Add is_realm_admin and is_guest setters. 2019-12-09 11:54:01 -08:00
tornado tornado: Add transitional code for sender_delivery_email. 2019-11-20 17:31:11 -08:00
views register: Allow creating non-ldap users via social backends. 2019-12-02 17:44:11 -08:00
webhooks integrations: Deduplicate gogs and gitea integrations. 2019-11-18 12:08:09 -08:00
worker queue workers: Use self.queue_name in retry_event calls. 2019-12-04 10:08:48 -08:00
__init__.py
apps.py cleanup: Delete leading newlines. 2019-08-06 23:29:11 -07:00
context_processors.py context: Rename social_backends to external_authentication_methods. 2019-11-03 15:55:44 -08:00
decorator.py decorator: Extract require_user_group_edit_permission. 2019-11-18 15:13:29 -08:00
filters.py cleanup: Delete leading newlines. 2019-08-06 23:29:11 -07:00
forms.py auth: Use zxcvbn to ensure password strength on server side. 2019-11-21 10:23:37 -08:00
logging_handlers.py version: Only let `git describe` match tags beginning with a digit. 2019-10-24 14:54:45 -07:00
middleware.py middleware: Fix exception typing. 2019-07-31 12:23:20 -07:00
models.py models: Add is_realm_admin and is_guest setters. 2019-12-09 11:54:01 -08:00
signals.py onboarding: Use delivery_email in "new login" notifications. 2019-11-14 12:19:47 -08:00