Controls whether the given User may log in. This is a policy setting, independent of end-user authentication. This default behavior is to allow login by active users, and reject login by inactive users. If the given user cannot log in, this method should raise a
(self, user)
| 357 | return self.cleaned_data |
| 358 | |
| 359 | def confirm_login_allowed(self, user): |
| 360 | """ |
| 361 | Controls whether the given User may log in. This is a policy setting, |
| 362 | independent of end-user authentication. This default behavior is to |
| 363 | allow login by active users, and reject login by inactive users. |
| 364 | |
| 365 | If the given user cannot log in, this method should raise a |
| 366 | ``ValidationError``. |
| 367 | |
| 368 | If the given user may log in, this method should return None. |
| 369 | """ |
| 370 | if not user.is_active: |
| 371 | raise ValidationError( |
| 372 | self.error_messages["inactive"], |
| 373 | code="inactive", |
| 374 | ) |
| 375 | |
| 376 | def get_user(self): |
| 377 | return self.user_cache |