mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-08-28 11:37:23 +08:00
feat(auth): enhance auxiliary authentication
This commit is contained in:
+2
-20
@@ -1,11 +1,7 @@
|
||||
from typing import Tuple, Any
|
||||
|
||||
from sqlalchemy import Boolean, Column, Integer, String, Sequence, JSON
|
||||
from sqlalchemy import Boolean, Column, Integer, JSON, Sequence, String
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.core.security import verify_password
|
||||
from app.db import db_query, db_update, Base
|
||||
from app.utils.otp import OtpUtils
|
||||
from app.db import Base, db_query, db_update
|
||||
|
||||
|
||||
class User(Base):
|
||||
@@ -35,20 +31,6 @@ class User(Base):
|
||||
# 用户个性化设置 json
|
||||
settings = Column(JSON, default=dict)
|
||||
|
||||
@staticmethod
|
||||
@db_query
|
||||
def authenticate(db: Session, name: str, password: str,
|
||||
otp_password: str) -> Tuple[bool, Any]:
|
||||
user = db.query(User).filter(User.name == name).first()
|
||||
if not user:
|
||||
return False, None
|
||||
if not verify_password(password, str(user.hashed_password)):
|
||||
return False, user
|
||||
if user.is_otp:
|
||||
if not otp_password or not OtpUtils.check(str(user.otp_secret), otp_password):
|
||||
return False, user
|
||||
return True, user
|
||||
|
||||
@staticmethod
|
||||
@db_query
|
||||
def get_by_name(db: Session, name: str):
|
||||
|
||||
Reference in New Issue
Block a user