Esempio n. 1
0
def setup_g2a_verify(request, val):
   
    CachedKey = 'qr_' + str(request.user.id)
    cache = caching()
    Secret = cache.get(CachedKey, False)  

    if not Secret:
       return json_false500(request)
    
    if g2f.auth(Secret, val):
       
        Setting = None    
        SettingType = CustomSettings.objects.get(title = "g2a")
        try :
            Setting = UserCustomSettings.objects.get(user  = request.user, setting = SettingType ) 
        except UserCustomSettings.DoesNotExist: 
            Setting = UserCustomSettings(user  = request.user, 
                                         setting = SettingType, 
                                         value = SettingType.def_value )
            
        valid_image =  settings.ROOT_PATH + "qr_images/qr_%i.png" % (request.user.id)
        os.remove(valid_image) 
        Setting.value = Secret
        Setting.save()
        request.session['use_f2a'] = True
        return json_true(request) 
    else :
        return json_false500(request)     
Esempio n. 2
0
def setup_g2a_verify(request, val):
    CachedKey = 'qr_' + str(request.user.id)
    cache = caching()
    Secret = cache.get(CachedKey, False)

    if not Secret:
        return json_false500(request)

    if g2f.auth(Secret, val):

        Setting = None
        SettingType = CustomSettings.objects.get(title="g2a")
        try:
            Setting = UserCustomSettings.objects.get(user=request.user,
                                                     setting=SettingType)
        except UserCustomSettings.DoesNotExist:
            Setting = UserCustomSettings(user=request.user,
                                         setting=SettingType,
                                         value=SettingType.def_value)

        valid_image = settings.ROOT_PATH + "qr_images/qr_%i.png" % (
            request.user.id)
        os.remove(valid_image)
        Setting.value = Secret
        Setting.save()
        request.session['use_f2a'] = True
        return json_true(request)
    else:
        return json_false500(request)
Esempio n. 3
0
def user_settings(Req, Name, Value):
        if not Req.user.is_authenticated():
                return json_denied(Req, {"ru_description": u"Для изменения персональных настроек пожайлуста авторизируйтесь"})
  
        if Value == "yes":
                Value = "yes"
        else:
                Value = "no"
                
        Setting = None
        try : 
              Setting = CustomSettings.objects.get(title = Name)
              Object = UserCustomSettings.objects.get(user  = Req.user, setting = Setting  )
              Object.value = Value
              Object.save()
              return json_true(Req)
        except UserCustomSettings.DoesNotExist:  
              obj = UserCustomSettings(user  = Req.user, setting = Setting, value = Value  )
              obj.save()
              return json_true(Req)
Esempio n. 4
0
def user_settings(Req, Name, Value):
    if not Req.user.is_authenticated():
        return json_denied(
            Req, {
                "ru_description":
                u"Для изменения персональных настроек пожайлуста авторизируйтесь"
            })

    if Value == "yes":
        Value = "yes"
    else:
        Value = "no"

    Setting = None
    try:
        Setting = CustomSettings.objects.get(title=Name)
        Object = UserCustomSettings.objects.get(user=Req.user, setting=Setting)
        Object.value = Value
        Object.save()
        return json_true(Req)
    except UserCustomSettings.DoesNotExist:
        obj = UserCustomSettings(user=Req.user, setting=Setting, value=Value)
        obj.save()
        return json_true(Req)