示例#1
0
 def notify(cls, request, message=None, force=False):
     obj = cls.objects.filter(user=request.user)
     if (obj.exists() and obj[0].enabled) or force:
         obj = UserAuthPhone.objects.filter(user=request.user)
         message = message if message else SMS_NOTIFICATION_MESSAGE
         if obj.exists():
             send_sms(SMS_FROM, Sign().unsign(obj[0].phone), message)
         elif request.user.email:
             send_mail(
                 [request.user.email], MAIL_DEFAULT_SUBJECT, message)
示例#2
0
 def notify(cls, request, message=None, force=False):
     obj = cls.objects.filter(user=request.user)
     if (obj.exists() and obj[0].enabled) or force:
         obj = UserAuthPhone.objects.filter(user=request.user)
         message = message if message else SMS_NOTIFICATION_MESSAGE
         if obj.exists():
             send_sms(SMS_FROM, Sign().unsign(obj[0].phone), message)
         elif request.user.email:
             send_mail(
                 [request.user.email], MAIL_DEFAULT_SUBJECT, message)
示例#3
0
 def send_link(cls, request, user):
     data = {
         'ip': get_ip(request),
         'user_agent': md5(request.META.get('HTTP_USER_AGENT')),
     }
     link = 'http://%s%s?data=%s' % (
         Site.objects.get_current(),
         reverse('auth_login'),
         Sign().sign(data)
     )
     send_mail(
         [user.email], _('Link for unlock access'), link
     )
示例#4
0
 def send_link(cls, request, user):
     data = {
         'ip': get_ip(request),
         'user_agent': md5(request.META.get('HTTP_USER_AGENT')),
     }
     link = 'http://%s%s?data=%s' % (
         Site.objects.get_current(),
         reverse('auth_login'),
         Sign().sign(data)
     )
     send_mail(
         [user.email], _('Link for unlock access'), link
     )
示例#5
0
    def send_codes(cls, request):
        settings_list = cls.objects.filter(user=request.user)

        if settings_list.exists():
            created_seconds = (now() - settings_list[0].created).seconds
            if created_seconds > 300:
                return

            codes = json.loads(Sign().unsign(settings_list[0].code))
            codes_list = collections.OrderedDict(
                sorted(codes.items(), key=lambda t: int(t[0])))
            message = ''
            for (k, v) in codes_list.items():
                message += '%s. %s\n' % (k, v)
            send_mail(
                [request.user.email], CODES_SUBJECT, message
            )
            return True
示例#6
0
    def send_codes(cls, request):
        settings_list = cls.objects.filter(user=request.user)

        if settings_list.exists():
            created_seconds = (now() - settings_list[0].created).seconds
            if created_seconds > 300:
                return

            codes = json.loads(Sign().unsign(settings_list[0].code))
            codes_list = collections.OrderedDict(
                sorted(codes.items(), key=lambda t: int(t[0])))
            message = ''
            for (k, v) in codes_list.items():
                message += '%s. %s\n' % (k, v)
            send_mail(
                [request.user.email], CODES_SUBJECT, message
            )
            return True