|
21 | 21 | from osf.models import OSFUser |
22 | 22 | from osf.utils.fields import ensure_str |
23 | 23 | from website import settings |
| 24 | +from framework import sentry |
24 | 25 |
|
25 | 26 | SessionStore = import_module(api_settings.SESSION_ENGINE).SessionStore |
26 | 27 |
|
@@ -92,6 +93,20 @@ def check_user(user): |
92 | 93 | # For all other cases, the user status is invalid. Although such status can't be reached with |
93 | 94 | # normal user-facing web application flow, it is still possible as a result of direct database |
94 | 95 | # access, coding bugs, database corruption, etc. |
| 96 | + extra_data = { |
| 97 | + 'user_id': user.id, |
| 98 | + 'user_guid': user._id, |
| 99 | + 'is_active': user.is_active, |
| 100 | + 'is_disabled': user.is_disabled, |
| 101 | + 'is_merged': user.is_merged, |
| 102 | + 'date_disabled': user.date_disabled, |
| 103 | + 'is_confirmed': user.is_confirmed, |
| 104 | + 'is_registered': user.is_registered, |
| 105 | + 'can_login': user.has_usable_password() or ( |
| 106 | + 'VERIFIED' in sum([list(each.values()) for each in user.external_identity.values()], []) |
| 107 | + ), |
| 108 | + } |
| 109 | + sentry.log_message(f'Invalid user account status detected: user_id={user._id}', extra_data=extra_data) |
95 | 110 | raise InvalidAccountError |
96 | 111 |
|
97 | 112 |
|
|
0 commit comments