예제 #1
0
def pin_change_do(Req):
    if not Req.user.is_authenticated():
        return denied(Req)

    Form = PinChangeForm(Req.POST, user=Req.user)
    Dict = {}

    if Form.is_valid():
        pin_name = settings.ROOT_PATH + "pins_images/pin_%i.png" % (
            Req.user.id)
        (Letters, Value) = pin(pin_name)
        i = None
        try:
            i = PinsImages.objects.get(user=Req.user)
        except PinsImages.DoesNotExist:
            i = PinsImages(user=Req.user, img=pin_name)

        i.req_vocabulary = Letters
        i.hash_value = generate_key_from(Value, settings.PIN_SALT)
        i.operator = Req.user
        i.status = "created"
        i.save()
        ##устанавливаем холд на вывод
        Key = start_show_pin(Req.user.id, 160000)
        return redirect("/pin_image_page/%s" % (Key))
    else:
        t = loader.get_template("simple_form.html")
        Dict = {}
        Dict["form"] = Form.as_p()
        Dict["action"] = "/profile/pin_change_do"
        Dict["action_title"] = settings.pin_change_title
        Dict["pin_load"] = True
        return http_tmpl_context(Req, t, Dict)
예제 #2
0
def pin_change_do(Req):
    if not Req.user.is_authenticated():
             return denied(Req)
     
    Form = PinChangeForm(Req.POST,  user = Req.user)  
    Dict = {}
    
    if Form.is_valid():
          pin_name = settings.ROOT_PATH + "pins_images/pin_%i.png" % (Req.user.id)
          (Letters, Value) = pin(pin_name)
          i = None
          try:
                  i = PinsImages.objects.get(user = Req.user)
          except PinsImages.DoesNotExist:
                  i = PinsImages(user = Req.user,
                                 img = pin_name
                                 )
          
          i.req_vocabulary  = Letters
          i.hash_value = generate_key_from(Value, settings.PIN_SALT)
          i.operator = Req.user
          i.status = "processed"
          i.save()
                ##устанавливаем холд на вывод 
          Key = start_show_pin(Req.user.id, 160000)      
          return redirect( "/pin_image_page/%s" % (Key) ) 
    else :
        t = loader.get_template("simple_form.html")   
        Dict = {}
        Dict["form"] = Form.as_p()
        Dict["action"] = "/profile/pin_change_do"
        Dict["action_title"] = settings.pin_change_title
        Dict["pin_load"] = True
        return http_tmpl_context(Req, t, Dict)
예제 #3
0
 def handle(self, *args, **options):
     for one_user  in User.objects.all():
         if not  one_user.is_staff and one_user.is_active:
             Key1 = generate_key()
             Key2 = generate_key()
             PrivateKey = generate_key_from(Key1, one_user.email)
             new_obj = ApiKeys(public_key = Key2, private_key = PrivateKey, user = one_user)
             new_obj.save()
예제 #4
0
    def clean(self):
        CheckPin = None
        try:
            CheckPin = self.fields["pin"].value
        except:
            raise forms.ValidationError(_(u"Вы неправильно ввели PIN-код "))

        Pin = None
        try:
            Pin = PinsImages.objects.get(user=self.__user)
        except PinsImages.DoesNotExist:
            raise forms.ValidationError(_(u"Обратитесь в службу поддержки, что бы получить pin-код для вывода "))

        if Pin.hash_value != generate_key_from(CheckPin, settings.PIN_SALT):
            raise forms.ValidationError(_(u"Вы неправильно ввели PIN-код "))

        return self.cleaned_data
예제 #5
0
  def clean(self):
    CheckPin = None      
    try:
            CheckPin = self.fields["pin"].value
    except :
            raise forms.ValidationError(_(u"Вы неправильно ввели PIN-код "))
    
    Pin = None
    try:
       Pin =  PinsImages.objects.get( user = self.__user )      
    except PinsImages.DoesNotExist:
       raise forms.ValidationError(_(u"Обратитесь в службу поддержки, что бы получить pin-код для вывода "))
    
    if Pin.hash_value != generate_key_from(CheckPin, settings.PIN_SALT):
             raise forms.ValidationError(_(u"Вы неправильно ввели PIN-код "))
 
    return self.cleaned_data
예제 #6
0
파일: views.py 프로젝트: kostyll/stock2
def new_api_key(one_user):
    Key1 = generate_key()
    Key2 = generate_key()
    PrivateKey = generate_key_from(Key1, one_user.email)
    new_obj = ApiKeys(public_key=Key2, private_key=PrivateKey, user=one_user)
    new_obj.save()
예제 #7
0
def new_api_key(one_user):
    Key1 = generate_key()
    Key2 = generate_key()
    PrivateKey = generate_key_from(Key1, one_user.email)
    new_obj = ApiKeys(public_key=Key2, private_key=PrivateKey, user=one_user)
    new_obj.save()