Skip to content

Instantly share code, notes, and snippets.

@twyle
Last active June 2, 2022 12:10
Show Gist options
  • Select an option

  • Save twyle/d4fa561ce10bfbd6b695118e7affc49f to your computer and use it in GitHub Desktop.

Select an option

Save twyle/d4fa561ce10bfbd6b695118e7affc49f to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
"""This module contains the database models used by the auth blueprint."""
from dataclasses import dataclass
from flask_dance.consumer.storage.sqla import OAuthConsumerMixin
from flask_login import UserMixin
from ..extensions import db
@dataclass
class User(UserMixin, db.Model):
"""A class that represents a user.
Attributes
----------
id: int
The unique user identifier
username: str
The unique name identifying a user
"""
id: int = db.Column(db.Integer, primary_key=True)
username: str = db.Column(db.String(250), unique=True)
@dataclass
class OAuth(OAuthConsumerMixin, db.Model):
"""This class stores the user authentication information.
Attributes
----------
user_id: str
The unique user identifier, same as the User.id
user: User
The user found in the users table
"""
user_id: int = db.Column(db.Integer, db.ForeignKey(User.id))
user: User = db.relationship(User)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment