root 1 месяц назад
Родитель
Сommit
c8598f557a
2 измененных файлов: 16 добавлений и 16 удалений
  1. 10
    10
      app/api/v1/auth.py
  2. 6
    6
      app/services/user_service.py

+ 10
- 10
app/api/v1/auth.py Просмотреть файл

59
                 "user_id": user.id,
59
                 "user_id": user.id,
60
                 "type": "refresh"
60
                 "type": "refresh"
61
             },
61
             },
62
-            expires_days=7
62
+            expires_days = 7
63
         )
63
         )
64
         
64
         
65
         # 构建用户响应
65
         # 构建用户响应
75
         }
75
         }
76
         
76
         
77
         return TokenResponse(
77
         return TokenResponse(
78
-            access_token=access_token,
79
-            token_type="bearer",
80
-            expires_in=settings.ACCESS_TOKEN_EXPIRE_MINUTES * 60,
81
-            refresh_token=refresh_token,
82
-            user=user_response
78
+            access_token = access_token,
79
+            token_type = "bearer",
80
+            expires_in = settings.ACCESS_TOKEN_EXPIRE_MINUTES * 60,
81
+            refresh_token = refresh_token,
82
+            user = user_response
83
         )
83
         )
84
         
84
         
85
     except ValueError as e:
85
     except ValueError as e:
86
         raise HTTPException(
86
         raise HTTPException(
87
-            status_code=status.HTTP_400_BAD_REQUEST,
88
-            detail=str(e)
87
+            status_code = status.HTTP_400_BAD_REQUEST,
88
+            detail = str(e)
89
         )
89
         )
90
     except Exception as e:
90
     except Exception as e:
91
         raise HTTPException(
91
         raise HTTPException(
92
-            status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
93
-            detail=f"注册失败: {str(e)}"
92
+            status_code = status.HTTP_500_INTERNAL_SERVER_ERROR,
93
+            detail = f"注册失败: {str(e)}"
94
         )
94
         )
95
 
95
 
96
 @router.post("/login", response_model=TokenResponse)
96
 @router.post("/login", response_model=TokenResponse)

+ 6
- 6
app/services/user_service.py Просмотреть файл

43
         
43
         
44
         # 创建用户对象
44
         # 创建用户对象
45
         user = User(
45
         user = User(
46
-            username=user_data.username,
47
-            email=user_data.email,
48
-            hashed_password=hashed_password,
49
-            full_name=user_data.full_name,
50
-            is_active=True,
51
-            is_verified=False
46
+            username = user_data.username,
47
+            email = user_data.email,
48
+            hashed_password = hashed_password,
49
+            full_name = user_data.full_name,
50
+            is_active = True,
51
+            is_verified = False
52
         )
52
         )
53
         
53
         
54
         # 异步保存
54
         # 异步保存