Setup login stuff

This commit is contained in:
iamBadgers
2026-05-02 10:36:26 -07:00
parent 79f8dacd52
commit 4a04e15d2a
3 changed files with 32 additions and 12 deletions

View File

@@ -1,12 +1,13 @@
from sqlalchemy import Column, ForeignKey, Integer, Table
from sqlalchemy import ForeignKey
from sqlalchemy.orm import relationship
from main import db
from werkzeug.security import generate_password_hash, check_password_hash
from flask_login import UserMixin
def create_new_session(user: User) -> Session:
return
class User(db.Model):
class User(UserMixin, db.Model):
__tablename__ = "users"
@@ -19,10 +20,10 @@ class User(db.Model):
self.password_hash = generate_password_hash(newPassword)
def test_password(self, password: str) -> bool:
return self.check_password_hash(password)
return check_password_hash(self.password_hash, password)
def to_dict(self):
return {"username": self.user_name}
return {"username": self.user_name, "authenticated": self.is_authenticated}
class Session(db.Model):