Example #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)     
Example #2
0
def login_f2a(request):
    key = request.REQUEST.get('key', None)
    password = request.REQUEST.get('password', None)
    cache = caching()
    UserIdCached = cache.get(key, False)
    if not UserIdCached:
        return json_false500(request)

    UserIdCachedInt = int(UserIdCached)
    Setting = UserCustomSettings.objects.get(user_id=UserIdCachedInt, setting__title="g2a")

    if auth(Setting.value, password):

        user = User.objects.get(id=UserIdCachedInt)
        user.backend = 'django.contrib.auth.backends.ModelBackend'
        login(request, user)
        request.result_auth = "good"
        request.session['auth_user_computered'] = True
        request.session['use_f2a'] = True
        request.session['user_id'] = user.id
        request.session['username'] = user.username
        request.session['email'] = user.email
        ComisObj = UserCustomSettings.objects.get(user_id=request.user.id, setting__title="deal_comission")
        DealComission = format_numbers4(Decimal(ComisObj.value) * Decimal("100"))
        request.session["deal_comission_show"] = DealComission
        request.session["deal_comission"] = format_numbers4(Decimal(ComisObj.value))

        notify_email(user, "auth_notify", request)

        return HttpResponse("good")

    else:
        return json_false500(request)
Example #3
0
def login_f2a(request):
    key = request.REQUEST.get('key', None)
    password = request.REQUEST.get('password', None)
    cache = caching()
    UserIdCached = cache.get(key, False)
    if not UserIdCached:
        return json_false500(request)

    UserIdCachedInt = int(UserIdCached)
    Setting = UserCustomSettings.objects.get(user_id=UserIdCachedInt, setting__title="g2a")

    if auth(Setting.value, password):

        user = User.objects.get(id=UserIdCachedInt)
        user.backend = 'django.contrib.auth.backends.ModelBackend'
        login(request, user)
        request.result_auth = "good"
        request.session['auth_user_computered'] = True
        request.session['use_f2a'] = True
        request.session['user_id'] = user.id
        request.session['username'] = user.username
        request.session['email'] = user.email
        ComisObj = UserCustomSettings.objects.get(user_id=request.user.id, setting__title="deal_comission")
        DealComission = format_numbers4(Decimal(ComisObj.value) * Decimal("100"))
        request.session["deal_comission_show"] = DealComission
        request.session["deal_comission"] = format_numbers4(Decimal(ComisObj.value))

        notify_email(user, "auth_notify", request)

        return HttpResponse("good")

    else:
        return json_false500(request)
Example #4
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)
Example #5
0
def login_f2a_operation(request):
    password = request.REQUEST.get('password', None)
    UserIdCachedInt = request.user.id
    Setting = UserCustomSettings.objects.get(user_id=UserIdCachedInt, setting__title="g2a")
    if auth(Setting.value, password):
        cache = caching()
        Key = "f2a_" + generate_key("fa_")
        cache.set(Key, UserIdCachedInt, 20)
        return HttpResponse(Key)
    return json_false500(request)
Example #6
0
def login_f2a_operation(request):
    password = request.REQUEST.get('password', None)
    UserIdCachedInt = request.user.id
    Setting = UserCustomSettings.objects.get(user_id=UserIdCachedInt, setting__title="g2a")
    if auth(Setting.value, password):
        cache = caching()
        Key = "f2a_" + generate_key("fa_")
        cache.set(Key, UserIdCachedInt, 20)
        return HttpResponse(Key)
    return json_false500(request)