Skip to content

Commit a7e5c85

Browse files
authored
更新用户登录时间函数名和依赖 (#52)
1 parent 3e05034 commit a7e5c85

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

backend/app/admin/crud/crud_user.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ async def get_by_username(self, db: AsyncSession, username: str) -> User | None:
3434
"""
3535
return await self.select_model_by_column(db, username=username)
3636

37-
async def update_user_login_time(self, db: AsyncSession, username: str, login_time: datetime) -> int:
37+
async def update_login_time(self, db: AsyncSession, username: str, login_time: datetime) -> int:
3838
user = await db.execute(
3939
update(self.model).where(self.model.username == username).values(last_login_time=login_time)
4040
)

backend/app/admin/service/auth_service.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ async def user_verify(username: str, password: str) -> User:
3232
async def swagger_login(self, *, form_data: OAuth2PasswordRequestForm) -> tuple[str, User]:
3333
async with async_db_session() as db:
3434
user = await self.user_verify(form_data.username, form_data.password)
35-
await user_dao.update_user_login_time(db, user.username, login_time=timezone.now())
35+
await user_dao.update_login_time(db, user.username, login_time=timezone.now())
3636
token = create_access_token(str(user.id))
3737
return token, user
3838

@@ -48,7 +48,7 @@ async def login(self, *, request: Request, obj: Auth2) -> GetLoginToken:
4848
raise errors.ForbiddenError(msg='验证码失效,请重新获取')
4949
if redis_code.lower() != obj.captcha.lower():
5050
raise errors.CustomError(error=CustomErrorCode.CAPTCHA_ERROR)
51-
await user_dao.update_user_login_time(db, user.username, login_time=timezone.now())
51+
await user_dao.update_login_time(db, user.username, login_time=timezone.now())
5252
token = create_access_token(str(user.id))
5353
data = GetLoginToken(access_token=token, user=user)
5454
return data

pyproject.toml

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ dependencies = [
2323
"redis[hiredis]==5.0.4",
2424
"SQLAlchemy==2.0.30",
2525
"tzdata==2024.1",
26-
"uvicorn[standard]==0.29.0",
2726
"sqlalchemy-crud-plus>=1.6.0",
2827
"pwdlib>=0.2.1",
2928
"msgspec>=0.18.6",

0 commit comments

Comments
 (0)