rest_framework_security/allowed_ips/protection.py
def successful_auth(self):
        """The credentials entered are correct, but access can still be denied"""
        action, user_ip = self.get_action()
        user_ip_is_new = user_ip is None
        if not user_ip:
            # It's the first time using this ip address
            user_ip = UserIp.objects.create(
                action="",
                ip_address=self.ip,
                last_used_at=timezone.now(),
                user=self.user,
            )
        else:
            user_ip.last_used_at = timezone.now()
            user_ip.save()
        if action == "deny" and user_ip_is_new:
            # Only send email and save ip if credenciales are valid
            DenyNewIpEmail(self.user, self.ip).send()
        if action == "deny":
            raise PermissionDenied(detail=f"Your ip {self.ip} is not authorized")
        if action == "warn" and user_ip_is_new:
            # Only send email and save ip if credenciales are valid
            WarnNewIpEmail(self.user, self.ip).send()
        elif user_ip.action == "warn":
            WarnIpEmail(self.user, self.ip).send()
The credentials entered are correct, but access can still be denied
The credentials entered are correct, but access can still be denied
The credentials entered are correct but access can still be denied
def successful_auth(self):
        action, user_ip = self.get_action()
        user_ip_is_new = user_ip is None
        if not user_ip:
            user_ip = UserIp.objects.create(
                action="",
                ip_address=self.ip,
                last_used_at=timezone.now(),
                user=self.user,
            )
        else:
            user_ip.last_used_at = timezone.now()
            user_ip.save()
        if action == "deny" and user_ip_is_new:
            DenyNewIpEmail(self.user, self.ip).send()
        if action == "deny":
            raise PermissionDenied(detail=f"Your ip {self.ip} is not authorized")
        if action == "warn" and user_ip_is_new:
            WarnNewIpEmail(self.user, self.ip).send()
        elif user_ip.action == "warn":
            WarnIpEmail(self.user, self.ip).send()
def successful_auth ( self ) : action , user_ip = self . get_action ( ) user_ip_is_new = user_ip is None if not user_ip : user_ip = UserIp . objects . create ( action = "" , ip_address = self . ip , last_used_at = timezone . now ( ) , user = self . user , ) else : user_ip . last_used_at = timezone . now ( ) user_ip . save ( ) if action == "deny" and user_ip_is_new : DenyNewIpEmail ( self . user , self . ip ) . send ( ) if action == "deny" : raise PermissionDenied ( detail = f"Your ip {self.ip} is not authorized" ) if action == "warn" and user_ip_is_new : WarnNewIpEmail ( self . user , self . ip ) . send ( ) elif user_ip . action == "warn" : WarnIpEmail ( self . user , self . ip ) . send ( )
The credentials entered are correct, but access can still be denied
The credentials entered are correct but access can still be denied
"""The credentials entered are correct, but access can still be denied""" # It's the first time using this ip address # Only send email and save ip if credenciales are valid # Only send email and save ip if credenciales are valid
self