Skip to content

Commit

Permalink
Fix - Remove password_hash size limit (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
daxAKAhackerman authored May 26, 2021
1 parent a0c1115 commit d159771
Show file tree
Hide file tree
Showing 8 changed files with 1,452 additions and 1,168 deletions.
5 changes: 3 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ psycopg2-binary = "==2.8.6"
waitress = "==1.4.3"
Flask = "==1.1.2"
Flask-Cors = "==3.0.10"
Flask-Migrate = "==2.7.0"
Flask-Migrate = "==3.0.0"
Flask-SQLAlchemy = "==2.5.1"
Flask-JWT-Extended = "==4.0.2"
requests = "==2.25.1"

[dev-packages]
black = "==20.8b1"
black = "==21.5b1"
isort = "*"
pre-commit = "*"
pytest = "*"
pytest-cov = "*"
pipenv = "*"

[requires]
python_version = "3.8"
535 changes: 251 additions & 284 deletions Pipfile.lock

Large diffs are not rendered by default.

2,014 changes: 1,147 additions & 867 deletions client/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"devDependencies": {
"@vue/cli-plugin-babel": "~4.3.0",
"@vue/cli-plugin-eslint": "~4.3.0",
"@vue/cli-service": "~4.3.0",
"@vue/cli-service": "^4.5.13",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2",
Expand Down
2 changes: 1 addition & 1 deletion server/app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class User(db.Model):

id = db.Column(db.Integer, primary_key=True, nullable=False)
username = db.Column(db.String(128), unique=True, nullable=False)
password_hash = db.Column(db.String(95), nullable=False)
password_hash = db.Column(db.Text, nullable=False)
first_login = db.Column(db.Boolean, nullable=False, default=True)
is_admin = db.Column(db.Boolean, nullable=False, default=False)
client = db.relationship("Client", backref="owner", lazy="dynamic")
Expand Down
22 changes: 10 additions & 12 deletions server/migrations/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@
# Interpret the config file for Python logging.
# This line sets up loggers basically.
fileConfig(config.config_file_name)
logger = logging.getLogger('alembic.env')
logger = logging.getLogger("alembic.env")

# add your model's MetaData object here
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
from flask import current_app
config.set_main_option(
'sqlalchemy.url', current_app.config.get(
'SQLALCHEMY_DATABASE_URI').replace('%', '%%'))
target_metadata = current_app.extensions['migrate'].db.metadata

config.set_main_option("sqlalchemy.url", current_app.config.get("SQLALCHEMY_DATABASE_URI").replace("%", "%%"))
target_metadata = current_app.extensions["migrate"].db.metadata

# other values from the config, defined by the needs of env.py,
# can be acquired:
Expand All @@ -46,9 +45,7 @@ def run_migrations_offline():
"""
url = config.get_main_option("sqlalchemy.url")
context.configure(
url=url, target_metadata=target_metadata, literal_binds=True
)
context.configure(url=url, target_metadata=target_metadata, literal_binds=True, compare_type=True)

with context.begin_transaction():
context.run_migrations()
Expand All @@ -66,15 +63,15 @@ def run_migrations_online():
# when there are no changes to the schema
# reference: http://alembic.zzzcomputing.com/en/latest/cookbook.html
def process_revision_directives(context, revision, directives):
if getattr(config.cmd_opts, 'autogenerate', False):
if getattr(config.cmd_opts, "autogenerate", False):
script = directives[0]
if script.upgrade_ops.is_empty():
directives[:] = []
logger.info('No changes in schema detected.')
logger.info("No changes in schema detected.")

connectable = engine_from_config(
config.get_section(config.config_ini_section),
prefix='sqlalchemy.',
prefix="sqlalchemy.",
poolclass=pool.NullPool,
)

Expand All @@ -83,7 +80,8 @@ def process_revision_directives(context, revision, directives):
connection=connection,
target_metadata=target_metadata,
process_revision_directives=process_revision_directives,
**current_app.extensions['migrate'].configure_args
**current_app.extensions["migrate"].configure_args,
compare_type=True
)

with context.begin_transaction():
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""Remove password_hash size limit
Revision ID: 9a220b2c1ca7
Revises: e4614ffaa6ae
Create Date: 2021-05-25 21:06:27.390670
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '9a220b2c1ca7'
down_revision = 'e4614ffaa6ae'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('user', schema=None) as batch_op:
batch_op.alter_column('password_hash',
existing_type=sa.VARCHAR(length=95),
type_=sa.Text(),
existing_nullable=False)

# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('user', schema=None) as batch_op:
batch_op.alter_column('password_hash',
existing_type=sa.Text(),
type_=sa.VARCHAR(length=95),
existing_nullable=False)

# ### end Alembic commands ###
2 changes: 1 addition & 1 deletion server/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Flask==1.1.2
Flask-Cors==3.0.10
Flask-Migrate==2.7.0
Flask-Migrate==3.0.0
Flask-SQLAlchemy==2.5.1
psycopg2-binary==2.8.6
waitress==1.4.3
Expand Down

0 comments on commit d159771

Please sign in to comment.