Пример #1
0
def wrongCred(index: int):
    auth.credentials = auth.buildCredentials(0, '', '', 0, 0)
    headers.jsonAPI(False)
    time.sleep(1)
    _mobile.elog('Credentials error - ' + str(index), 'auth')
    headers.errorResponse(translation.getValue('user_not_found'))
Пример #2
0
def badExit(index: int):
    auth.credentials = auth.buildCredentials(0, '', '', 0, 0)
    headers.jsonAPI(False)
    time.sleep(1)
    _mobile.elog('Request error - ' + str(index), 'reg')
    headers.errorResponse(translation.getValue('bad_request'))
Пример #3
0
#!/usr/local/bin/python3
import inspect
import os
import sys

currentdir = os.path.dirname(
    os.path.abspath(inspect.getfile(inspect.currentframe())))
sys.path.insert(0, os.path.dirname(os.path.dirname(currentdir)))
from _common.api import auth
from _common.api import headers
from mobile_service.apiv1 import _mobile

headers.jsonAPI()
devid = auth.user_some_state
if (auth._POST is None):  # only POST accepted
    _mobile.elog('No posted info uid:' + auth.user_id)
    headers.errorResponse('Wrong information')
json = auth._POST
if 'need_tasks' not in json:
    _mobile.elog('Incorrect tasks uid:' + auth.user_id)
    headers.errorResponse('Nothing was sent')
tasks = json['need_tasks']
if len(tasks) < 1:
    headers.errorResponse('No requested information was sent')
obj = _mobile.getTotalIdsString(user_id=auth.user_id,
                                devid=auth.user_some_state,
                                cross=tasks,
                                extendType=1)
if obj is None:
    headers.errorResponse('SQL error')
headers.goodResponse(obj)
Пример #4
0
    badExit(2)

if 'password' not in jsonpost:
    badExit(3)

if 'device' not in jsonpost:
    badExit(4)

if ('crc32_control' not in jsonpost) or ('crc32_str' not in jsonpost):
    badExit(5)
crc32_control = int(jsonpost['crc32_control'])
if crc32_control != utils.crc32(str(jsonpost['crc32_str'])):
    auth.credentials = auth.buildCredentials(0, '', '', 0, 0)
    headers.jsonAPI(False)
    time.sleep(1)
    _mobile.elog('CRC32 control mistake', 'critical')
    headers.errorResponse("CRC32 algorithm error")

if len(jsonpost['login']) < 4 or len(jsonpost['password']) < 4 or len(
        jsonpost['device']) < 4:
    auth.credentials = auth.buildCredentials(0, '', '', 0, 0)
    headers.jsonAPI(False)
    time.sleep(1)
    _mobile.elog('Too short symbols', 'auth')
    headers.errorResponse(translation.getValue('mobile_too_short'))

jsonpost['remember'] = -1
if auth.isMobile:  # Yes only from Mobile!!!
    jsonpost['remember'] = 1
else:
    badExit(6)
Пример #5
0
import sys

currentdir = os.path.dirname(
    os.path.abspath(inspect.getfile(inspect.currentframe())))
sys.path.insert(0, os.path.dirname(os.path.dirname(currentdir)))
from _common.api import auth
from _common.api import headers
from _common.api import utils
from _common.api import db
from mobile_service.apiv1 import _mobile
from _common.api import translation

headers.jsonAPI()
devid = auth.user_some_state
if (auth._POST is None):  # only POST accepted
    _mobile.elog('No posted info uid:' + auth.user_id)
    headers.errorResponse('Wrong information')
json = auth._POST
if 'tasks' not in json:
    _mobile.elog('Incorrect info format uid:' + auth.user_id)
    headers.errorResponse('Nothing was sent')
tasks = json['tasks']

mobile_crc32 = json['sync_info']['crc32']
mobile_time = json['sync_info']['time']
mobile_serial = json['sync_info']['serial']
mobile_count = json['sync_info']['count']
saved_ids = []
broken_ids = []
remove_ids = []
# headers.errorResponse('error n-' + str(len(data)))