def send_reset_password_link(request): ''' Send email with reset password link. ''' if not registration_settings.RESET_PASSWORD_VERIFICATION_ENABLED: raise Http404() serializer = SendResetPasswordLinkSerializer(data=request.data) serializer.is_valid(raise_exception=True) login = serializer.validated_data['login'] user = None for login_field in get_login_fields(): user = get_user_by_lookup_dict({login_field: login}, default=None) if user: break if not user: raise UserNotFound() signer = ResetPasswordSigner({ 'user_id': user.pk, }, request=request) template_config = ( registration_settings.RESET_PASSWORD_VERIFICATION_EMAIL_TEMPLATES) send_verification_notification(user, signer, template_config) return get_ok_response('Reset link sent')
def _get_user_by_login_or_none(self, login): user = None for login_field in get_user_login_fields(): user = get_user_by_lookup_dict({login_field: login}, default=None, require_verified=False) if user: break return user
def _get_user_by_email_or_none(self, email): email_field_name = get_user_email_field_name() return get_user_by_lookup_dict({email_field_name: email}, default=None, require_verified=False)
def _get_user_by_email_or_none(self, email): email_field = get_user_setting('EMAIL_FIELD') return get_user_by_lookup_dict({email_field: email}, default=None, require_verified=False)