MCPcopy
hub / github.com/django/django / confirm_login_allowed

Method confirm_login_allowed

django/contrib/auth/forms.py:359–374  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 1

cleanMethod · 0.95

Calls 1

ValidationErrorClass · 0.90

Tested by

no test coverage detected