Beispiel #1
0
    def find(id):
        from db.models import User

        s = current_session()

        try:
            uid = int(id)
            uid = uid if uid < 500000 else None
        except ValueError:
            uid = None

        if not uid:
            return None

        q = s.query(User)
        user = q.filter(User.id == uid).first()

        return user
Beispiel #2
0
    def find(id):
        from db.models import User

        s = current_session()

        try:
            uid = int(id)
            uid = uid if uid < 500000 else None
        except ValueError:
            uid = None

        if not uid:
            return None

        q = s.query(User)
        user = q.filter(User.id == uid).first()

        return user
Beispiel #3
0
    def find(id):
        from db.models import DiscuzMember, User
        from sqlalchemy.orm import joinedload

        s = current_session()

        try:
            uid = int(id)
            uid = uid if uid < 500000 else None
        except ValueError:
            uid = None

        q = s.query(DiscuzMember).options(joinedload('ucmember'))
        if uid:
            dz_member = q.filter(DiscuzMember.uid == uid).first()
        else:
            dz_member = q.filter(DiscuzMember.email == id).first()
            dz_member = dz_member or q.filter(DiscuzMember.username == id).first()

        if not dz_member:
            return None

        uid = dz_member.uid
        user = s.query(User).filter(User.id == uid).first()
        if not user:
            user = User()
            s.add(user)

        user.dz_member = dz_member

        # sync
        user.games    = dz_member.member_count.games
        user.drops    = dz_member.member_count.drops
        user.jiecao   = dz_member.member_count.jiecao

        return user
Beispiel #4
0
    def authenticate(cls, username, password):
        from db.models import User

        try:
            uid = int(username)
        except:
            return None

        user = cls.find(username)
        if not user:
            s = current_session()

            user = User()
            user.id = uid
            user.username = str(username)
            user.email = str(username)
            user.credits = 998
            user.games = 1
            user.drops = 0

            s.add(user)
            s.flush()

        return cls()._fill_account(user)
Beispiel #5
0
    def find(id):
        from db.models import DiscuzMember, User
        from sqlalchemy.orm import joinedload

        s = current_session()

        try:
            uid = int(id)
            uid = uid if uid < 500000 else None
        except ValueError:
            uid = None

        q = s.query(DiscuzMember).options(joinedload('ucmember'))
        if uid:
            dz_member = q.filter(DiscuzMember.uid == uid).first()
        else:
            dz_member = q.filter(DiscuzMember.email == id).first()
            dz_member = dz_member or q.filter(DiscuzMember.username == id).first()

        if not dz_member:
            return None

        uid = dz_member.uid
        user = s.query(User).filter(User.id == uid).first()
        if not user:
            user = User()
            s.add(user)

        user.dz_member = dz_member

        # sync
        user.games    = dz_member.member_count.games
        user.drops    = dz_member.member_count.drops
        user.jiecao   = dz_member.member_count.jiecao

        return user
Beispiel #6
0
    def authenticate(cls, username, password):
        from db.models import User

        try:
            uid = int(username)
        except:
            return None

        user = cls.find(username)
        if not user:
            s = current_session()

            user = User()
            user.id = uid
            user.username = str(username)
            user.email = str(username)
            user.credits = 998
            user.games = 1
            user.drops = 0

            s.add(user)
            s.flush()

        return cls()._fill_account(user)