feat: 扩展后端认证功能,支持短信验证码
- 扩展auth.py路由,添加短信验证码相关接口 - 更新database/models.py数据模型,支持短信验证
This commit is contained in:
@@ -137,7 +137,24 @@ class RefreshToken(Base):
|
||||
expires_at = Column(DateTime(timezone=True), nullable=False) # 过期时间(30天后)
|
||||
created_at = Column(DateTime(timezone=True), default=utc_now)
|
||||
is_revoked = Column(Boolean, default=False) # 是否已撤销
|
||||
device_info = Column(String, nullable=True) # 设备信息(用于全设备登出)
|
||||
|
||||
# Relationships
|
||||
user = relationship("User", back_populates="refresh_tokens")
|
||||
|
||||
|
||||
class SmsVerificationCode(Base):
|
||||
"""短信验证码表"""
|
||||
__tablename__ = "sms_verification_codes"
|
||||
|
||||
id = Column(String, primary_key=True)
|
||||
phone = Column(String, nullable=False, index=True) # 手机号
|
||||
code = Column(String, nullable=False) # 6位验证码
|
||||
purpose = Column(String, nullable=False) # register/login/reset_password/change_phone
|
||||
is_used = Column(Boolean, default=False) # 是否已使用
|
||||
is_expired = Column(Boolean, default=False) # 是否已过期
|
||||
expires_at = Column(DateTime(timezone=True), nullable=False) # 过期时间(5分钟后)
|
||||
created_at = Column(DateTime(timezone=True), default=utc_now)
|
||||
verified_at = Column(DateTime(timezone=True), nullable=True) # 验证时间
|
||||
ip_address = Column(String, nullable=True) # 请求IP地址
|
||||
|
||||
|
||||
Reference in New Issue
Block a user