Skip to content

Commit

Permalink
feat(app):
Browse files Browse the repository at this point in the history
- add email service
- fix security problem
  • Loading branch information
MorvanZhou committed Sep 13, 2024
1 parent d68157d commit d7eb794
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/retk/core/account/app_captcha.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from collections import OrderedDict
from collections import OrderedDict as OD
from datetime import datetime
from io import BytesIO
from random import choices
from typing import Tuple, Dict
from typing import Tuple, Dict, OrderedDict

from captcha.audio import AudioCaptcha
from captcha.image import ImageCaptcha
Expand All @@ -19,7 +19,7 @@
alphabet_len = len(alphabet)
code_idx_range = list(range(0, alphabet_len - 1))

cache_captcha: OrderedDict[str, Tuple[datetime, str]] = OrderedDict()
cache_captcha: OrderedDict[str, Tuple[datetime, str]] = OD()


def generate(length: int = 4, sound: bool = False) -> Tuple[str, Dict[str, BytesIO]]:
Expand Down
6 changes: 3 additions & 3 deletions src/retk/core/account/email.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from collections import OrderedDict
from collections import OrderedDict as OD
from datetime import datetime
from typing import List, Dict, Tuple
from typing import List, Dict, Tuple, OrderedDict

from retk import const, config, regex, utils
from retk.core import scheduler
Expand Down Expand Up @@ -64,7 +64,7 @@ def _send(self, recipients: List[str], subject: str, template_id: int, values: D

email_server = EmailServer()

cache_email: OrderedDict[str, Tuple[datetime, str]] = OrderedDict()
cache_email: OrderedDict[str, Tuple[datetime, str]] = OD()


def encode_number(number: str, expired_min: int) -> str:
Expand Down
3 changes: 1 addition & 2 deletions src/retk/core/utils/cached_verification.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from collections import OrderedDict
from datetime import timedelta, datetime
from typing import Tuple
from typing import Tuple, OrderedDict

from retk import const
from retk.utils.auth import short_uuid
Expand Down

0 comments on commit d7eb794

Please sign in to comment.