Setup login stuff
This commit is contained in:
@@ -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):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user