~vesto/feedon

1ac264e15a91efbfb580c8f8fd78a2424b838658 — Steve Gattuso 6 months ago 3e71699
fix user storage bugs
2 files changed, 18 insertions(+), 5 deletions(-)

M feedon/blueprints/auth.py
M feedon/db/__init__.py
M feedon/blueprints/auth.py => feedon/blueprints/auth.py +14 -4
@@ 99,11 99,21 @@ def complete():
    )

    user_data = verify_resp.json()
    user = db.User.create(
        instance_domain=instance_domain,
        access_token=access_token,
        handle=user_data['username'],

    # Check to see if the user already exists
    user = db.User.get_or_none(
        (db.User.instance_domain == instance_domain) &
        (db.User.handle == user_data['username'])
    )
    if user is None:
        user = db.User.create(
            instance_domain=instance_domain,
            access_token=access_token,
            handle=user_data['username'],
        )
    else:
        user.access_token = access_token
        user.save()

    session['user_id'] = user.id


M feedon/db/__init__.py => feedon/db/__init__.py +4 -1
@@ 18,8 18,8 @@ class Instance(peewee.Model):

class User(peewee.Model):
    id = peewee.AutoField()
    handle = peewee.CharField()
    instance_domain = peewee.CharField()
    handle = peewee.CharField()
    access_token = peewee.CharField()

    def get_client(self):


@@ 37,6 37,9 @@ class User(peewee.Model):
    class Meta:
        table_name = 'users'
        database = db
        indexes = (
            (('instance_domain', 'handle'), True),
        )

class Timeline(peewee.Model):
    id = peewee.AutoField()