mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
fix(fastapi): fix SessionID (and ResetKey) generation
Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
d658627e99
commit
47feb72f48
4 changed files with 12 additions and 35 deletions
|
@ -1,8 +1,7 @@
|
|||
from sqlalchemy.exc import IntegrityError
|
||||
from sqlalchemy.orm import backref, relationship
|
||||
|
||||
from aurweb import schema
|
||||
from aurweb.db import make_random_value, query
|
||||
from aurweb import db, schema
|
||||
from aurweb.models.declarative import Base
|
||||
from aurweb.models.user import User as _User
|
||||
|
||||
|
@ -19,8 +18,8 @@ class Session(Base):
|
|||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
|
||||
user_exists = query(
|
||||
query(_User).filter(_User.ID == self.UsersID).exists()
|
||||
user_exists = db.query(
|
||||
db.query(_User).filter(_User.ID == self.UsersID).exists()
|
||||
).scalar()
|
||||
if not user_exists:
|
||||
raise IntegrityError(
|
||||
|
@ -31,4 +30,4 @@ class Session(Base):
|
|||
|
||||
|
||||
def generate_unique_sid():
|
||||
return make_random_value(Session, Session.SessionID)
|
||||
return db.make_random_value(Session, Session.SessionID, 32)
|
||||
|
|
|
@ -230,3 +230,7 @@ class User(Base):
|
|||
def __repr__(self):
|
||||
return "<User(ID='%s', AccountType='%s', Username='%s')>" % (
|
||||
self.ID, str(self.AccountType), self.Username)
|
||||
|
||||
|
||||
def generate_unique_resetkey():
|
||||
return db.make_random_value(User, User.ResetKey, 32)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue