Resolved code formatting change requests
This commit is contained in:
parent
bedc03b18f
commit
9c13c6ae56
6 changed files with 37 additions and 30 deletions
|
@ -1,13 +1,11 @@
|
|||
from typing import Tuple
|
||||
|
||||
import hashlib
|
||||
import random
|
||||
from collections import OrderedDict
|
||||
from nacl import pwhash
|
||||
from nacl.exceptions import InvalidkeyError
|
||||
|
||||
from szurubooru import config, model, errors, db
|
||||
from szurubooru.func import util
|
||||
from nacl import pwhash
|
||||
|
||||
|
||||
RANK_MAP = OrderedDict([
|
||||
|
|
|
@ -243,8 +243,10 @@ def update_user_password(user: model.User, password: str) -> None:
|
|||
raise InvalidPasswordError(
|
||||
'Password must satisfy regex %r.' % password_regex)
|
||||
user.password_salt = auth.create_password()
|
||||
hash, revision = auth.get_password_hash(user.password_salt, password)
|
||||
user.password_hash = hash
|
||||
password_hash, revision = auth.get_password_hash(
|
||||
user.password_salt,
|
||||
password)
|
||||
user.password_hash = password_hash
|
||||
user.password_revision = revision
|
||||
|
||||
|
||||
|
|
|
@ -38,8 +38,7 @@ def run_migrations_offline():
|
|||
url=url,
|
||||
target_metadata=target_metadata,
|
||||
literal_binds=True,
|
||||
compare_type=True
|
||||
)
|
||||
compare_type=True)
|
||||
|
||||
with alembic.context.begin_transaction():
|
||||
alembic.context.run_migrations()
|
||||
|
@ -61,8 +60,7 @@ def run_migrations_online():
|
|||
alembic.context.configure(
|
||||
connection=connection,
|
||||
target_metadata=target_metadata,
|
||||
compare_type=True
|
||||
)
|
||||
compare_type=True)
|
||||
|
||||
with alembic.context.begin_transaction():
|
||||
alembic.context.run_migrations()
|
||||
|
|
|
@ -47,11 +47,14 @@ class User(Base):
|
|||
|
||||
|
||||
def upgrade():
|
||||
op.alter_column('user', 'password_hash',
|
||||
op.alter_column(
|
||||
'user',
|
||||
'password_hash',
|
||||
existing_type=sa.VARCHAR(length=64),
|
||||
type_=sa.Unicode(length=128),
|
||||
existing_nullable=False)
|
||||
op.add_column('user', sa.Column('password_revision',
|
||||
op.add_column('user', sa.Column(
|
||||
'password_revision',
|
||||
sa.SmallInteger(),
|
||||
nullable=True,
|
||||
default=0))
|
||||
|
@ -69,12 +72,17 @@ def upgrade():
|
|||
session.flush()
|
||||
session.commit()
|
||||
|
||||
op.alter_column('user', 'password_revision',
|
||||
existing_nullable=True, nullable=False)
|
||||
op.alter_column(
|
||||
'user',
|
||||
'password_revision',
|
||||
existing_nullable=True,
|
||||
nullable=False)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.alter_column('user', 'password_hash',
|
||||
op.alter_column(
|
||||
'user',
|
||||
'password_hash',
|
||||
existing_type=sa.Unicode(length=128),
|
||||
type_=sa.VARCHAR(length=64),
|
||||
existing_nullable=False)
|
||||
|
|
|
@ -25,8 +25,8 @@ class User(Base):
|
|||
name = sa.Column('name', sa.Unicode(50), nullable=False, unique=True)
|
||||
password_hash = sa.Column('password_hash', sa.Unicode(128), nullable=False)
|
||||
password_salt = sa.Column('password_salt', sa.Unicode(32))
|
||||
password_revision = sa.Column('password_revision', sa.SmallInteger,
|
||||
default=0, nullable=False)
|
||||
password_revision = sa.Column(
|
||||
'password_revision', sa.SmallInteger, default=0, nullable=False)
|
||||
email = sa.Column('email', sa.Unicode(64), nullable=True)
|
||||
rank = sa.Column('rank', sa.Unicode(32), nullable=False)
|
||||
avatar_style = sa.Column(
|
||||
|
|
|
@ -115,7 +115,8 @@ def config_injector():
|
|||
|
||||
@pytest.fixture
|
||||
def user_factory():
|
||||
def factory(name=None,
|
||||
def factory(
|
||||
name=None,
|
||||
rank=model.User.RANK_REGULAR,
|
||||
email='dummy',
|
||||
password_salt=None,
|
||||
|
|
Loading…
Reference in a new issue