From aa717a4ef9d45d0b2a454a75bdd4f55dd18a2225 Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Fri, 3 Dec 2021 15:41:54 -0800 Subject: [PATCH] change(fastapi): no longer care about ResetKey collisions Signed-off-by: Kevin Morris --- aurweb/models/user.py | 6 +++--- aurweb/routers/accounts.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/aurweb/models/user.py b/aurweb/models/user.py index 8e66b490..d0bdea30 100644 --- a/aurweb/models/user.py +++ b/aurweb/models/user.py @@ -15,7 +15,7 @@ import aurweb.config import aurweb.models.account_type import aurweb.schema -from aurweb import db, logging, schema +from aurweb import db, logging, schema, util from aurweb.models.account_type import AccountType as _AccountType from aurweb.models.ban import is_banned from aurweb.models.declarative import Base @@ -249,5 +249,5 @@ class User(Base): self.ID, str(self.AccountType), self.Username) -def generate_unique_resetkey(): - return db.make_random_value(User, User.ResetKey, 32) +def generate_resetkey(): + return util.make_random_string(32) diff --git a/aurweb/routers/accounts.py b/aurweb/routers/accounts.py index 388daf84..f61ccdd2 100644 --- a/aurweb/routers/accounts.py +++ b/aurweb/routers/accounts.py @@ -16,7 +16,7 @@ from aurweb.exceptions import ValidationError from aurweb.l10n import get_translator_for_request from aurweb.models import account_type as at from aurweb.models.ssh_pub_key import get_fingerprint -from aurweb.models.user import generate_unique_resetkey +from aurweb.models.user import generate_resetkey from aurweb.scripts.notify import ResetKeyNotification, WelcomeNotification from aurweb.templates import make_context, make_variable_context, render_template from aurweb.users import update, validate @@ -93,7 +93,7 @@ async def passreset_post(request: Request, status_code=HTTPStatus.SEE_OTHER) # If we got here, we continue with issuing a resetkey for the user. - resetkey = generate_unique_resetkey() + resetkey = generate_resetkey() with db.begin(): user.ResetKey = resetkey @@ -291,7 +291,7 @@ async def account_register_post(request: Request, # Create a user with no password with a resetkey, then send # an email off about it. - resetkey = generate_unique_resetkey() + resetkey = generate_resetkey() # By default, we grab the User account type to associate with. atype = db.query(models.AccountType,