|
2 | 2 | # -*- coding: utf-8 -*-
|
3 | 3 | import datetime
|
4 | 4 | import os
|
5 |
| -import re |
6 | 5 | from hashlib import sha256
|
7 | 6 |
|
8 | 7 | import aiofiles
|
9 | 8 | from email_validator import EmailNotValidError, validate_email
|
10 |
| -from fast_captcha import tCaptcha |
| 9 | +from fast_captcha import text_captcha |
11 | 10 | from fastapi import APIRouter, Depends, File, HTTPException, Request, Response, status, UploadFile, BackgroundTasks
|
12 | 11 | from fastapi.security import OAuth2PasswordRequestForm
|
13 | 12 | from fastapi_pagination.ext.async_sqlalchemy import paginate
|
@@ -107,7 +106,7 @@ async def get_email_login_code(request: Request, email: ELCode, tasks: Backgroun
|
107 | 106 | if not current_user.is_active:
|
108 | 107 | raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail='该用户已被锁定,无法登录,发送验证码失败', headers=headers)
|
109 | 108 | try:
|
110 |
| - code = tCaptcha() |
| 109 | + code = text_captcha() |
111 | 110 | tasks.add_task(send_email_verification_code, email.email, code, SEND_EMAIL_LOGIN_TEXT)
|
112 | 111 | except Exception as e:
|
113 | 112 | log.exception('验证码发送失败 {}', e)
|
@@ -185,7 +184,7 @@ async def user_register(create: CreateUser, db: AsyncSession = Depends(get_db)):
|
185 | 184 | @user.post('/password_reset_code', summary='获取密码重置验证码', description='可以通过用户名或者邮箱重置密码')
|
186 | 185 | async def password_reset_code(username_or_email: str, response: Response, tasks: BackgroundTasks,
|
187 | 186 | db: AsyncSession = Depends(get_db)):
|
188 |
| - code = tCaptcha() |
| 187 | + code = text_captcha() |
189 | 188 | if await user_crud.get_user_by_username(db, username_or_email):
|
190 | 189 | try:
|
191 | 190 | response.delete_cookie(key='fast-code')
|
|
0 commit comments