refactor(api): move create password
This commit is contained in:
parent
edfd2c1159
commit
8f3fde623f
@ -6,10 +6,9 @@ from typing import Optional
|
|||||||
from sqlalchemy import func, insert, select
|
from sqlalchemy import func, insert, select
|
||||||
from sqlalchemy.ext.asyncio import AsyncConnection
|
from sqlalchemy.ext.asyncio import AsyncConnection
|
||||||
|
|
||||||
from api.db.logic.keyring import create_password_key
|
|
||||||
from api.db.tables.account import account_table
|
from api.db.tables.account import account_table
|
||||||
from api.schemas.account.account import User
|
from api.schemas.account.account import User
|
||||||
from api.schemas.endpoints.account import all_user_adapter, AllUser, AllUserResponse, UserCreate, UserUpdate
|
from api.schemas.endpoints.account import all_user_adapter, AllUser, AllUserResponse, UserCreate
|
||||||
|
|
||||||
|
|
||||||
async def get_user_accaunt_page(connection: AsyncConnection, page, limit) -> Optional[AllUserResponse]:
|
async def get_user_accaunt_page(connection: AsyncConnection, page, limit) -> Optional[AllUserResponse]:
|
||||||
@ -123,6 +122,5 @@ async def create_user(connection: AsyncConnection, user: UserCreate, creator_id:
|
|||||||
|
|
||||||
await connection.commit()
|
await connection.commit()
|
||||||
new_user = await get_user_by_id(connection, res.lastrowid)
|
new_user = await get_user_by_id(connection, res.lastrowid)
|
||||||
await create_password_key(connection, user.password, new_user.id)
|
|
||||||
|
|
||||||
return new_user
|
return new_user
|
||||||
|
@ -14,6 +14,7 @@ from api.db.logic.account import (
|
|||||||
get_user_by_login,
|
get_user_by_login,
|
||||||
update_user_by_id,
|
update_user_by_id,
|
||||||
)
|
)
|
||||||
|
from api.db.logic.keyring import create_password_key
|
||||||
from api.db.tables.account import AccountStatus
|
from api.db.tables.account import AccountStatus
|
||||||
from api.schemas.account.account import User
|
from api.schemas.account.account import User
|
||||||
from api.schemas.base import bearer_schema
|
from api.schemas.base import bearer_schema
|
||||||
@ -73,6 +74,7 @@ async def create_account(
|
|||||||
|
|
||||||
if user_validation is None:
|
if user_validation is None:
|
||||||
new_user = await create_user(connection, user, authorize_user.id)
|
new_user = await create_user(connection, user, authorize_user.id)
|
||||||
|
await create_password_key(connection, user.password, new_user.id)
|
||||||
return new_user
|
return new_user
|
||||||
else:
|
else:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
Loading…
Reference in New Issue
Block a user