feature:新增邮箱注册登录功能

This commit is contained in:
xiamuceer
2026-03-20 11:06:25 +08:00
parent 7df6f52a9e
commit d72dd1c555
16 changed files with 2074 additions and 349 deletions
@@ -0,0 +1,64 @@
"""新增stmp相关配置
Revision ID: 6eb27fce64de
Revises: 8e3ac0236b27
Create Date: 2026-03-20 09:36:42.899296
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = '6eb27fce64de'
down_revision: Union[str, None] = '8e3ac0236b27'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('settings', sa.Column('smtp_provider', sa.String(length=50), server_default='qq', nullable=False, comment='SMTP 提供商'))
op.add_column('settings', sa.Column('smtp_host', sa.String(length=255), nullable=True, comment='SMTP 主机'))
op.add_column('settings', sa.Column('smtp_port', sa.Integer(), server_default='465', nullable=False, comment='SMTP 端口'))
op.add_column('settings', sa.Column('smtp_username', sa.String(length=255), nullable=True, comment='SMTP 用户名'))
op.add_column('settings', sa.Column('smtp_password', sa.String(length=500), nullable=True, comment='SMTP 密码或授权码'))
op.add_column('settings', sa.Column('smtp_use_tls', sa.Boolean(), server_default='0', nullable=False, comment='是否启用 TLS'))
op.add_column('settings', sa.Column('smtp_use_ssl', sa.Boolean(), server_default='1', nullable=False, comment='是否启用 SSL'))
op.add_column('settings', sa.Column('smtp_from_email', sa.String(length=255), nullable=True, comment='发件人邮箱'))
op.add_column('settings', sa.Column('smtp_from_name', sa.String(length=255), server_default='MuMuAINovel', nullable=False, comment='发件人名称'))
op.add_column('settings', sa.Column('email_auth_enabled', sa.Boolean(), server_default='1', nullable=False, comment='是否启用邮箱认证'))
op.add_column('settings', sa.Column('email_register_enabled', sa.Boolean(), server_default='1', nullable=False, comment='是否启用邮箱注册'))
op.add_column('settings', sa.Column('verification_code_ttl_minutes', sa.Integer(), server_default='10', nullable=False, comment='验证码有效期(分钟)'))
op.add_column('settings', sa.Column('verification_resend_interval_seconds', sa.Integer(), server_default='60', nullable=False, comment='验证码重发间隔(秒)'))
op.alter_column('settings', 'cover_enabled',
existing_type=sa.BOOLEAN(),
server_default='0',
existing_comment='是否启用封面图片生成',
existing_nullable=False)
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('settings', 'cover_enabled',
existing_type=sa.BOOLEAN(),
server_default=None,
existing_comment='是否启用封面图片生成',
existing_nullable=False)
op.drop_column('settings', 'verification_resend_interval_seconds')
op.drop_column('settings', 'verification_code_ttl_minutes')
op.drop_column('settings', 'email_register_enabled')
op.drop_column('settings', 'email_auth_enabled')
op.drop_column('settings', 'smtp_from_name')
op.drop_column('settings', 'smtp_from_email')
op.drop_column('settings', 'smtp_use_ssl')
op.drop_column('settings', 'smtp_use_tls')
op.drop_column('settings', 'smtp_password')
op.drop_column('settings', 'smtp_username')
op.drop_column('settings', 'smtp_port')
op.drop_column('settings', 'smtp_host')
op.drop_column('settings', 'smtp_provider')
# ### end Alembic commands ###
@@ -0,0 +1,70 @@
"""新增stmp相关配置
Revision ID: 6ff45db05863
Revises: 17ce752ed7cc
Create Date: 2026-03-20 09:39:23.544434
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = '6ff45db05863'
down_revision: Union[str, None] = '17ce752ed7cc'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('projects', schema=None) as batch_op:
batch_op.alter_column('cover_status',
existing_type=sa.VARCHAR(length=20),
server_default=None,
existing_nullable=False)
with op.batch_alter_table('settings', schema=None) as batch_op:
batch_op.add_column(sa.Column('smtp_provider', sa.String(length=50), server_default='qq', nullable=False, comment='SMTP 提供商'))
batch_op.add_column(sa.Column('smtp_host', sa.String(length=255), nullable=True, comment='SMTP 主机'))
batch_op.add_column(sa.Column('smtp_port', sa.Integer(), server_default='465', nullable=False, comment='SMTP 端口'))
batch_op.add_column(sa.Column('smtp_username', sa.String(length=255), nullable=True, comment='SMTP 用户名'))
batch_op.add_column(sa.Column('smtp_password', sa.String(length=500), nullable=True, comment='SMTP 密码或授权码'))
batch_op.add_column(sa.Column('smtp_use_tls', sa.Boolean(), server_default='0', nullable=False, comment='是否启用 TLS'))
batch_op.add_column(sa.Column('smtp_use_ssl', sa.Boolean(), server_default='1', nullable=False, comment='是否启用 SSL'))
batch_op.add_column(sa.Column('smtp_from_email', sa.String(length=255), nullable=True, comment='发件人邮箱'))
batch_op.add_column(sa.Column('smtp_from_name', sa.String(length=255), server_default='MuMuAINovel', nullable=False, comment='发件人名称'))
batch_op.add_column(sa.Column('email_auth_enabled', sa.Boolean(), server_default='1', nullable=False, comment='是否启用邮箱认证'))
batch_op.add_column(sa.Column('email_register_enabled', sa.Boolean(), server_default='1', nullable=False, comment='是否启用邮箱注册'))
batch_op.add_column(sa.Column('verification_code_ttl_minutes', sa.Integer(), server_default='10', nullable=False, comment='验证码有效期(分钟)'))
batch_op.add_column(sa.Column('verification_resend_interval_seconds', sa.Integer(), server_default='60', nullable=False, comment='验证码重发间隔(秒)'))
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('settings', schema=None) as batch_op:
batch_op.drop_column('verification_resend_interval_seconds')
batch_op.drop_column('verification_code_ttl_minutes')
batch_op.drop_column('email_register_enabled')
batch_op.drop_column('email_auth_enabled')
batch_op.drop_column('smtp_from_name')
batch_op.drop_column('smtp_from_email')
batch_op.drop_column('smtp_use_ssl')
batch_op.drop_column('smtp_use_tls')
batch_op.drop_column('smtp_password')
batch_op.drop_column('smtp_username')
batch_op.drop_column('smtp_port')
batch_op.drop_column('smtp_host')
batch_op.drop_column('smtp_provider')
with op.batch_alter_table('projects', schema=None) as batch_op:
batch_op.alter_column('cover_status',
existing_type=sa.VARCHAR(length=20),
server_default=sa.text("'none'"),
existing_nullable=False)
# ### end Alembic commands ###