示例#1
0
 def doLoginByMobile(cls, rpath):
     isReturn, params = AccountCheck.login_check(rpath, 2)
     if isReturn:
         return params
     mo = TyContext.Cls_MsgPack()
     AccountLogin.doLoginByMobile(params, mo)
     return mo
示例#2
0
 def doCreateAccount(cls, rpath):
     isReturn, params = AccountCheck.login_check(rpath, 7)
     if isReturn:
         return params
     mo = TyContext.Cls_MsgPack()
     AccountLogin.doCreateAccount(params, mo)
     return mo
示例#3
0
 def doRenewAuthorCodeByTyId(cls, rpath):
     isReturn, params = AccountCheck.login_check(rpath, 3)
     if isReturn:
         return params
     mo = TyContext.Cls_MsgPack()
     AccountLogin.doRenewAuthorCodeByTyId(params, mo)
     return mo
示例#4
0
 def doLoginByDevId(cls, rpath):
     isReturn, params = AccountCheck.login_check(rpath, 1, False)
     if isReturn:
         return params
     mo = TyContext.Cls_MsgPack()
     AccountLogin.doLoginByDevId(params, mo)
     return mo
示例#5
0
    def doBindBySnsId(cls, rparams, mo):
        TyContext.ftlog.info(cls.__name__, 'doBindBySnsId->rparams=', rparams)

        userId = rparams['userId']
        snsId = rparams['snsId']
        if snsId.startswith('360'):
            if Account360.doGetUserInfo(rparams, snsId) != True:
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', '360登录验证失败!')
                return
            else:
                snsId = rparams['snsId']

            # 绑定过程,不改变用户昵称
            if 'name' in rparams:
                del rparams['name']

        elif snsId.startswith('wx:'):
            if not AccountWeixin.doGetUserInfo(rparams, snsId):
                mo.setResult('code', AccountConst.CODE_USER_PARAM_ERROR)
                mo.setResult('info', 'wx登录验证失败!')
                #                TyContext.BiReport.report_bi_sdk_login(
                #                    TyContext.BIEventId.SDK_LOGIN_BY_SNSID_FAIL, 0,
                #                    rparams['appId'], rparams['clientId'], snsId,
                #                    AccountConst.CODE_USER_SNS_GETINFO_ERROR)
                return
            else:
                snsId = rparams['snsId']

        userIdBound = TyContext.RedisUserKeys.execute('GET',
                                                      'snsidmap:' + snsId)
        if userIdBound:
            TyContext.MySqlSwap.checkUserDate(userIdBound)
            AccountHelper.restore_avatar_verify_set(userIdBound)
            mo.setResult('code', 0)
            mo.setResult('info', '绑定成功')
            mo.setResult('binduserstyle', 2)
            AccountLogin.__do_login_done__(rparams, userIdBound, mo,
                                           AccountConst.USER_TYPE_SNS)
            return

        # V3版一个tyid可以绑定多个snsId
        TyContext.MySqlSwap.checkUserDate(userId)
        AccountHelper.restore_avatar_verify_set(userId)
        TyContext.RedisUser.execute(
            userId, 'HMSET', 'user:'******'snsId', snsId, 'isbind',
            AccountConst.USER_TYPE_SNS, 'bindTime',
            datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
        TyContext.RedisUserKeys.execute('SET', 'snsidmap:' + snsId, userId)
        mo.setResult('code', 0)
        mo.setResult('binduserstyle', 1)
        mo.setResult('info', '绑定成功')
        AccountLogin.__do_login_done__(rparams, userId, mo,
                                       AccountConst.USER_TYPE_SNS)
        cls.__bind_success_callback_(rparams['appId'], 'bindsnsid', {
            'appId': rparams['appId'],
            'userId': userId,
            'snsId': snsId
        })
示例#6
0
    def doLoginBySnsID(cls, rpath):
        isReturn, params = AccountCheck.login_check(rpath, 5)
        if isReturn:
            return params

        AccountCheck.set_user_check(rpath, params)
        mo = TyContext.Cls_MsgPack()
        AccountLogin.doProcessSnsID(params, mo)
        return mo
示例#7
0
    def doSetForbidden(cls, rpath):
        '''设置禁止登录用户'''
        mo = TyContext.Cls_MsgPack()
        lock_users = TyContext.RunHttp.getRequestParam('lock_users', '[]')
        unlock_users = TyContext.RunHttp.getRequestParam('unlock_users', '[]')

        try:
            locked = json.loads(lock_users)
            unlocked = json.loads(unlock_users)
        except:
            mo.setResult('code', 1)
            mo.setResult('info', 'error args')
            return mo

        byid = TyContext.RunHttp.getRequestParam('byid', 'userId')
        TyContext.ftlog.debug('doSetForbidden byid', byid, 'locked', locked,
                              'unlocked', unlocked)
        if byid == 'userId':
            return cls._set_forbidden_ids('forbidden:uid:', locked, unlocked, locked, mo, 100)
        elif byid == 'clientId':
            return cls._set_forbidden_ids('forbidden:cid:', locked, unlocked, locked, mo)
        elif byid == 'deviceId':
            lock_users = []
            for devid in locked:
                userid = AccountLogin.__find_userid_by_devid_map_v3__(devid)
                if userid > 0:
                    lock_users.append(userid)
            return cls._set_forbidden_ids('forbidden:devid:', locked, unlocked, lock_users, mo)
示例#8
0
 def doCallback(cls, rpath):
     postData = TyContext.RunHttp.get_body_content()
     TyContext.ftlog.debug('TuYouPayMumayi->doCallback, postData=',
                           postData)
     try:
         rparams = json.loads(postData)
     except:
         TyContext.ftlog.error(
             'TuYouPayMumayi->callback, json error !! postData=', postData)
         return 'error'
     # orderPlatformId = rparams['orderID']
     uid = rparams['uid']
     userId = AccountLogin.__find_userid_by_snsid__('mumayi:%s' % uid)
     chargeKey = 'sdk.charge:mumayi:%s' % userId
     platformOrderId, appKey = TyContext.RedisPayData.execute(
         'HMGET', chargeKey, 'platformOrderId', 'appKey')
     TyContext.ftlog.debug(
         'TuYouPayMumayi->get order info:',
         'userId=%s platformOrderId=%s appKey=%s' %
         (userId, platformOrderId, appKey))
     # payType = rparams['payType']
     # productName = rparams['productName']
     # productPrice = rparams['productPrice']
     # productDesc = rparams['productDesc']
     # orderTime = rparams['orderTime']
     # tradeSign = rparams['tradeSign']
     # tradeState = rparams['tradeState']
     if not cls.check_pay(rparams, appKey):
         TyContext.ftlog.error(
             'doIDOCallback->ERROR, sign error !! rparam=', rparams)
         return 'error'
     # do charge
     # from tysdk.entity.pay.pay import TuyouPay
     # trade_status = rparams['status']
     isOk = PayHelper.callback_ok(platformOrderId, -1, rparams)
     if isOk:
         return 'success'
     else:
         return 'error'
示例#9
0
 def doSnsLogin(cls, rpath):
     # todo 验签
     mo = TyContext.Cls_MsgPack()
     rparams = TyContext.RunHttp.convertArgsToDict()
     rparams['snsId'] = AccountVerify.decode_item(rparams['snsId'])
     snsId = rparams.get('snsId')
     prefix = snsId.split(':')[0]
     isOk = None
     try:
         method = snsv4_login_map.get(prefix)
         if not method:
             isOk = True
         else:
             isOk = method(rparams, snsId)
     except:
         isOk = False
     if not isOk:
         mo.setResult('info', '三方登陆失败')
         mo.setResult('code', 1)
         return mo
     userId = AccountLogin.__find_userid_by_snsid__(snsId)
     is_create = False
     if userId <= 0:
         # 效验该deviceId是否存在第三方sns刷号嫌疑
         isFlag, retMsg = AccountLogin._check_deviceid_sns_forbidden(
             rparams)
         if isFlag:
             mo.setResult('code', AccountConst.CODE_USER_SNS_REG_FAILE)
             mo.setResult('info', retMsg)
             return mo
         rparams['passwd'] = 'ty' + str(random.randint(100000, 999999))
         if snsId.startswith('360'):
             rparams['lang'] = "zh_hans"
         is_create = True
         userId = AccountInfo.createNewUser(rparams,
                                            AccountConst.USER_TYPE_SNS,
                                            False)
         if userId <= 0:
             mo.setResult('code', AccountConst.CODE_USER_GUEST_REG_FAILE)
             mo.setResult('info', '用户账号建立失败')
             return mo
         appId = rparams['appId']
     else:
         rparams['userId'] = userId
         try:
             del rparams['name']
         except:
             pass
         AccountInfo.doSetUserInfo(rparams, mo, False)
     AccountLogin._do_check_login(rparams, userId, mo,
                                  AccountConst.USER_TYPE_SNS, is_create)
     # add to userBindSet
     snsId = rparams.get('snsId')
     AccountModel.add_snsid_to_userbind_set(userId, snsId)
     retMsg = TyContext.Cls_MsgPack()
     if mo.getErrorInfo():
         retMsg.setResult('info', mo.getErrorInfo())
         retMsg.setResult('code', mo.getErrorCode())
         return retMsg
     token = AccountModel.reset_user_token(userId, 'sns')
     retMsg.setResult('token', token)
     retMsg.setResult('code', 0)
     return retMsg