mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-08-04 21:15:22 +02:00
Feature: Add "Authentication Method" to allow existing users to sign in with LDAP (#2143)
* adds authentication method for users * fix db migration with postgres * tests for auth method * update migration ids * hide auth method on user creation form * (docs): Added documentation for the new authentication method * update migration * add to auto-form instead of having hidden fields
This commit is contained in:
parent
39012adcc1
commit
2e6ad5da8e
24 changed files with 213 additions and 24 deletions
|
@ -0,0 +1,43 @@
|
|||
"""add auth_method to user table
|
||||
|
||||
Revision ID: 38514b39a824
|
||||
Revises: b04a08da2108
|
||||
Create Date: 2023-02-22 21:45:52.900964
|
||||
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
|
||||
import mealie.db.migration_types
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = "38514b39a824"
|
||||
down_revision = "b04a08da2108"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def is_postgres():
|
||||
return op.get_context().dialect.name == "postgresql"
|
||||
|
||||
|
||||
authMethod = sa.Enum("MEALIE", "LDAP", name="authmethod")
|
||||
|
||||
|
||||
def upgrade():
|
||||
if is_postgres():
|
||||
authMethod.create(op.get_bind())
|
||||
|
||||
op.add_column(
|
||||
"users",
|
||||
sa.Column("auth_method", authMethod, nullable=False, server_default="MEALIE"),
|
||||
)
|
||||
op.execute("UPDATE users SET auth_method = 'LDAP' WHERE password = 'LDAP'")
|
||||
|
||||
|
||||
def downgrade():
|
||||
with op.batch_alter_table("users", schema=None) as batch_op:
|
||||
batch_op.drop_column("auth_method")
|
||||
|
||||
if is_postgres():
|
||||
authMethod.drop(op.get_bind())
|
Loading…
Add table
Add a link
Reference in a new issue