コード例 #1
0
ファイル: wechat.py プロジェクト: endsh/chiki
def on_invite(user, uid):
    um = current_app.user_manager
    if not user.inviter and uid and uid != user.id:
        inviter = um.models.User.objects(id=uid).first()
        if inviter and inviter.active and inviter.is_allow_invite(user):
            ids = []
            ids.append(inviter.inviter.id if inviter.inviter else 0)
            ids.append(inviter.inviter2.id if inviter.inviter2 else 0)
            ids.append(inviter.inviter3.id if inviter.inviter3 else 0)
            if user.id not in ids:
                if inviter.is_allow_channel(user):
                    user.channel = inviter.channel
                user.inviter = inviter
                user.inviter2 = inviter.inviter
                user.inviter3 = inviter.inviter2
                user.save()

        if not inviter and uid < 100000:
            if not user.channel:
                channel = Channel.objects(id=uid).first()
                if channel:
                    user.channel = channel.id
                    user.inviter = um.models.User(id=100000)
                    user.save()
            else:
                user.channel = 1000
                user.inviter = um.models.User(id=100000)
                user.save()
コード例 #2
0
ファイル: wechat.py プロジェクト: next-backend/chiki
def on_invite(user, uid):
    um = current_app.user_manager
    if not user.inviter and uid and uid != user.id:
        inviter = um.models.User.objects(id=uid).first()
        if inviter and inviter.active and inviter.is_allow_invite(user):
            ids = []
            ids.append(inviter.inviter.id if inviter.inviter else 0)
            ids.append(inviter.inviter2.id if inviter.inviter2 else 0)
            ids.append(inviter.inviter3.id if inviter.inviter3 else 0)
            if user.id not in ids:
                if inviter.is_allow_channel(user):
                    user.channel = inviter.channel
                user.inviter = inviter
                user.inviter2 = inviter.inviter
                user.inviter3 = inviter.inviter2
                user.save()

        if not inviter and uid < 100000:
            if not user.channel:
                channel = Channel.objects(id=uid).first()
                if channel:
                    user.channel = channel.id
                    user.inviter = um.models.User(id=100000)
                    user.save()
            else:
                user.channel = 1000
                user.inviter = um.models.User(id=100000)
                user.save()
コード例 #3
0
ファイル: __init__.py プロジェクト: endsh/chiki
 def load_user(id):
     if type(id) in (str, unicode):
         if id.startswith('wechat:'):
             return um.models.WeChatUser.objects(id=id.split(':')[-1]).first()
         elif id.startswith('qq:'):
             return um.models.QQUser.objects(id=id.split(':')[-1]).first()
         elif id.startswith('weibo:'):
             return um.models.WeiBoUser.objects(id=id.split(':')[-1]).first()
         elif id.startswith('channel:'):
             return Channel.objects(id=int(id.split(':')[-1])).first()
     return um.models.User.objects(id=id).first()
コード例 #4
0
 def load_user(id):
     if type(id) in (str, unicode):
         if id.startswith('wechat:'):
             return um.models.WeChatUser.objects(
                 id=id.split(':')[-1]).first()
         elif id.startswith('qq:'):
             return um.models.QQUser.objects(
                 id=id.split(':')[-1]).first()
         elif id.startswith('weibo:'):
             return um.models.WeiBoUser.objects(
                 id=id.split(':')[-1]).first()
         elif id.startswith('channel:'):
             return Channel.objects(id=int(id.split(':')[-1])).first()
     return um.models.User.objects(id=id).first()
コード例 #5
0
        def load_user(id):
            id = str(id)
            if id.startswith('wechat:'):
                return um.models.WeChatUser.objects(
                    id=id.split(':')[-1]).first()
            elif id.startswith('qq:'):
                return um.models.QQUser.objects(id=id.split(':')[-1]).first()
            elif id.startswith('weibo:'):
                return um.models.WeiBoUser.objects(
                    id=id.split(':')[-1]).first()
            elif id.startswith('channel:'):
                return Channel.objects(id=int(id.split(':')[-1])).first()

            try:
                uid, s = id.rsplit(u'|', 1)
                user = um.models.User.objects(id=int(uid)).first()
                if user:
                    key = current_app.config.get('SECRET_KEY')
                    if s == sign(key, password=user.password):
                        return user
            except:
                pass