brestok commited on
Commit
e2a8a40
·
1 Parent(s): 9039c7f
cbh/api/security/utils.py CHANGED
@@ -7,30 +7,11 @@ import asyncio
7
  from fastapi import HTTPException
8
  from jinja2 import Environment, FileSystemLoader, select_autoescape
9
 
10
- from cbh.api.account.dto import RegistrationType
11
  from cbh.api.account.models import AccountModel, AccountShorten
12
  from cbh.api.security.models import VerificationCodeModel
13
  from cbh.core.config import settings
14
 
15
 
16
- def check_account_to_reset(
17
- account_obj: AccountModel, account: AccountModel | None = None
18
- ) -> None:
19
- """
20
- Check if the account can be reset.
21
- """
22
- if not account and account_obj.registrationType != RegistrationType.ORGANIC:
23
- raise HTTPException(
24
- status_code=422,
25
- detail="Please sign in with social providers",
26
- )
27
- elif account and account_obj.registrationType != RegistrationType.ORGANIC:
28
- raise HTTPException(
29
- status_code=422,
30
- detail="Password reset is not available for social login accounts",
31
- )
32
-
33
-
34
  async def send_password_reset_email(
35
  code: str, account_obj: AccountShorten
36
  ) -> None:
 
7
  from fastapi import HTTPException
8
  from jinja2 import Environment, FileSystemLoader, select_autoescape
9
 
 
10
  from cbh.api.account.models import AccountModel, AccountShorten
11
  from cbh.api.security.models import VerificationCodeModel
12
  from cbh.core.config import settings
13
 
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  async def send_password_reset_email(
16
  code: str, account_obj: AccountShorten
17
  ) -> None:
cbh/api/security/views.py CHANGED
@@ -22,7 +22,7 @@ from cbh.api.security.schemas import (
22
  LoginAccountResponse,
23
  RegisterCompleteRequest, ResetPasswordConfirmRequest,
24
  )
25
- from cbh.api.security.utils import check_account_to_reset, send_password_reset_email
26
  from cbh.core.security import PermissionDependency, create_access_token
27
  from cbh.core.wrappers import CbhResponseWrapper
28
 
@@ -108,7 +108,6 @@ async def request_password_reset_code(
108
  account_obj = await get_account_by_email(data.email)
109
  if not account_obj:
110
  return CbhResponseWrapper(data=None)
111
- check_account_to_reset(account_obj, account)
112
  account_obj = AccountShorten(**account_obj.model_dump())
113
  code = await create_code_obj(
114
  account_obj,
 
22
  LoginAccountResponse,
23
  RegisterCompleteRequest, ResetPasswordConfirmRequest,
24
  )
25
+ from cbh.api.security.utils import send_password_reset_email
26
  from cbh.core.security import PermissionDependency, create_access_token
27
  from cbh.core.wrappers import CbhResponseWrapper
28
 
 
108
  account_obj = await get_account_by_email(data.email)
109
  if not account_obj:
110
  return CbhResponseWrapper(data=None)
 
111
  account_obj = AccountShorten(**account_obj.model_dump())
112
  code = await create_code_obj(
113
  account_obj,