Ejemplo n.º 1
0
from utils.redis_utils import RedisUtils
from utils.logger_utils import LoggerUtils

logger = LoggerUtils('customer_service.index').logger
result = '<script>window.setTimeout(\"location.href = \'/customer_service/error\'\", 0);</script>\n'
try:
    redis = RedisUtils()
    if 'HTTP_COOKIE' in os.environ:
        cookie_string = os.environ.get('HTTP_COOKIE')
        logger.info('session:' + cookie_string)
        if cookie_string != '':
            c = Cookie.SimpleCookie()
            c.load(cookie_string)
            if 'session' in c:
                sessionid = c['session'].value
                if redis.exists(sessionid):
                    withdrawal_count = data_withdrawal.query_withdrawal_count_by_state(
                    )
                    stateall = 0
                    state0 = 0
                    state1 = 0
                    state2 = 0
                    if 0 in withdrawal_count:
                        state0 = withdrawal_count[0]
                        stateall += state0
                    if 1 in withdrawal_count:
                        state1 = withdrawal_count[1]
                        stateall += state1
                    if 2 in withdrawal_count:
                        state2 = withdrawal_count[2]
                        stateall += state2
Ejemplo n.º 2
0
result = '3'
header = ''
try:
    redis = RedisUtils()
    form = cgi.FieldStorage()
    if 'account_name' in form:
        account_name = form.getvalue('account_name')
        pswd = form.getvalue('pswd')
        customer_service = data_customer_service.query_by_account_name(
            account_name)
        if customer_service is not None:
            if StringUtils.md5(pswd) != customer_service.pswd:
                result = '2'
            else:
                sessionid = 'session' + StringUtils.randomStr(32)
                while redis.exists(sessionid):
                    sessionid = 'session' + StringUtils.randomStr(32)
                session = {}
                session['account_name'] = account_name
                redis.setexo(sessionid, session, 86400)
                header = 'Set-Cookie: session = "' + sessionid + '";path=/customer_service/'
                result = '0'
        else:
            result = '1'

except:
    logger.exception(traceback.format_exc())
print 'Access-Control-Allow-Credentials:true'
print header
print ''
print result